< Qt

Hello, World!

This is the Hello, World! program. It just displays a window:

#include <QApplication>
#include <QLabel>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    QLabel label("Hello, world!");
    label.show();
    return app.exec();
}

To compile this, read Development Environment

Using Qt designer

This lesson will get you started using Qt designer for making your own simple application.

Open Qt Designer and select to make a new dialog without buttons. Drag a label on to it and set its title property to "Hello, World!", then go to Form > Preview to see your new dialog. Now, onto writing some code. We'll have to subclass the QDialog class to make the application run standalone on most modern operating systems.

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.