A widget is never visible when you create it. You must callQWidget::show() to make it visible.
This is where
If you are developing Qt applications at the command line, you need to ensure that the Qt libraries andexecutables are accessible to your environment by prepending the path to Qt's
directory to your
variable; this is described in theInstallationinstructions for your platform.On Windows, this is automatically done for you if you get your command line prompt from the
menu. If you get your command line prompt with
, you have to set the
variable there yourself.
Building an application
The tutorial examples are located in the Qt
directory. If you installed a binary Qt package, pre-built examples were installed as well. If you built Qt yourself, the examples were built at the sametime. In either case, there is a lot to be learned about using Qt by modifying and building the examples yourself.Assuming you have copied an example's
files to an otherwise empty directory, and you have madeyour changes there, the next step is to create a Qt makefile in that directory. To create a Qt makefile, useqmake,the build tool supplied with Qt. Run the following two commands in the directory containing your modifiedsources to create the makefile.
The first command tells qmake to create a project (
) file. The second command tells qmake to use the
file to create a platform-specific makefile. Now you can just run
if you are using Visual Studio) to compile the program, and then you canrun your first Qt application!
Running this example
When you run the example, you will see a small window showing a single button. On the button you can readthe famous words: "Hello world!"
Try to resize the window. Click the button. If you are running X11, try running the program with the
Qt Tutorial 2 - Calling it Quits