#include #include #include #include #include int main(int argc, char *argv[]) { QApplication a(argc, argv); /** We create a new QMainWindow */ QMainWindow* mainWindow = new QMainWindow; /** We create a QFrame to work as * a central widget for the QMainWindow. */ QFrame* centralWidget = new QFrame(mainWindow); /** The central widget is set with * the QMainWindow::centralWidget */ mainWindow->setCentralWidget(centralWidget); /** We create a QVBoxLayout which provides us * positioning and widget resizing services. * QVBoxLayot does vertical layout so that widgets * are on above and below of each other. */ QVBoxLayout* layout = new QVBoxLayout(centralWidget); QLabel* label = new QLabel("Hello World", centralWidget); /** Ask it to be aligned to center. */ label->setAlignment(Qt::AlignCenter); /** Widgets are added to a layout with * simply calling QLayout::addWidget */ layout->addWidget(label); /** We show the main window. */ mainWindow->show(); /** Start the event loop. */ int returnValue = a.exec(); /** Call the QObject::deleteLater() to a deferred delete. */ mainWindow->deleteLater(); return returnValue; }