Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# main.cpp Example File
tutorial/t4/main.cpp

        /****************************************************************
        **
        ** Qt tutorial 4
        **
        ****************************************************************/

        #include <QApplication>
        #include <QFont>
        #include <QPushButton>

        class MyWidget : public QWidget
        {
        public:
            MyWidget(QWidget *parent = 0);
        };

        MyWidget::MyWidget(QWidget *parent)
            : QWidget(parent)
        {
            setFixedSize(200, 120);

            QPushButton *quit = new QPushButton("Quit", this);
            quit->setGeometry(62, 40, 75, 30);
            quit->setFont(QFont("Times", 18, QFont::Bold));

            connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
        }

        int main(int argc, char *argv[])
        {
            QApplication app(argc, argv);
            MyWidget widget;
            app.setMainWidget(&widget);
            widget.show();
            return app.exec();
        }