From Molkentin: // helloWorld/main.cpp #include #include int main(int argc, char *argv[]) { QApplication a(argc, argv); QLabel label("Hello World"); label.show(); return a.exec(); } // layout/main.cpp #include #include #include int main(int argc, char *argv[]) { QApplication a(argc, argv); // app on the stack QWidget window; // main widget on the stack QVBoxLayout* mainLayout = new QVBoxLayout(&window); // everyting else on the heap QLabel* label1 = new QLabel("One"); QLabel* label2 = new QLabel("Two"); mainLayout->addWidget(label1); // label1 becomes a child of mainLayout's parent mainLayout->addWidget(label2); // ditto window.show(); return a.exec(); }