Demo entry 6360088

test

   

Submitted by anonymous on Apr 30, 2017 at 23:26
Language: C++. Code size: 997 Bytes.

#include <QApplication>
#include <QPushButton>
#include <QVBoxLayout>
#include <QWidget>

class VerticalBox : public QWidget {
public:
    VerticalBox(QApplication *app, QWidget *parent = 0);

private slots:
    void OnClick();

private:
    QPushButton *quit;
    QApplication *app;
};

VerticalBox::VerticalBox(QApplication *app, QWidget *parent): QWidget(parent) {
    QVBoxLayout *vbox = new QVBoxLayout(this);

    QPushButton *quit = new QPushButton("quit");
    quit->setEnabled(true);
    vbox->addWidget(quit);

    connect(quit, &QPushButton::clicked, this, &VerticalBox::OnClick);

    setLayout(vbox);

    this->quit = quit;
    this->app = app;
}

void VerticalBox::OnClick() {
    quit->setEnabled(false);
    app->exit();
}

int main(int argc, char *argv[]) {
    QApplication app(argc, argv);

    VerticalBox window(&app);
    window.resize(250, 150);
    window.setWindowTitle("QEMU");
    window.show();

    return app.exec();
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).