To create a new project click on “New Project” and choose Applications, then QT Widget Application on the welcome page of QT Creator.
The first step is naming the project and setting the project path. In the next window you will have to select the kit which was created within this tutorial. The project in this tutorial is called 'HelloWorld_TQ'.
Upon creating the project you will find yourself in the Edit section of QT Creator, where you have access to all program files of the project. In the .pro file two lines need to be added.
target.path =
sets the target path on the device which will later running the QT application.
Also add
INSTALLS += target
before continuing to the next step.
If you want to use pictures or other files in your application you have to make sure the files are located in the project folder, then define installationpath and fileformat. To do that you have to add and adapt the following lines of code:
[prefix].path = [target-path] [prefix].files = *[file-format] INSTALLS += [prefix]
This is the complete code we used in this tutorial:
Double click on the .ui file in the 'Forms' folder to enter the Design tab.
In the lower right handside corner you can customize window title and resolution at which the application will be running.
Then drag & drop a 'Push Button' from the 'Buttons' Section into the main window. You can adjust the size of the button, by double clicking you can also edit the text.
Just for the looks we decided to add an image on top of the exit button. To do that you need to drag and drop a label from the 'Display Widgets' section and select the image file under 'pixmap' in the lower right hand corner.
To add functionality to the Exit button, click on the icon second from the left (Edit Signals/Slot) on the toolbar, then click the button and drag the link onto the main window. Upon doing that a new window will open, in which you need to tick 'show signals and slots inherited from QWidget' to show all options. Now set that clicking the button triggers the main window to close.
Lastly you need to go to the Projects tab, select the kit of the target system and add
-qws
to the arguments in the run section of the kit.
You also need to add the Variable
QWS_MOUSE_PROTO
with the Value
tslib:/dev/input/event0
to the runtime environment.
If “incremental deployment” is checked, program files will only be transferred if they have changed since the last deployment.
To launch the application select the kit and build by clicking the PC icon in the lower left handside, then press play.