User Tools

Site Tools


qt:helloworld

HelloWorld

Root widget on the stack

main.cpp
// main.cpp
 
#include <QApplication>
#include <QLabel>
 
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);         // create a QApplication (on the stack)
 
    QLabel label("Nice to meet you.");  // root widget (on the stack)
    label.show();                       // show it
 
    return a.exec();                    // start the event loop
}

Root widget on the heap

main.cpp
// main.cpp
 
#include <QApplication>
#include <QLabel>
 
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);         // create a QApplication (on the stack)
 
    QLabel* label = new QLabel("I'm on the heap!");
    label->show();
 
    return a.exec();                    // start the event loop
}
qt/helloworld.txt · Last modified: 2010/12/07 17:41 by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki