ZedBoard Learning Notes (8) Bigger goals!

To do GUI under Linux, the simpler method is to use QT. QT has been used for cross-platform application development, previously owned by Nokia, and is now sold to Digia, the open source version of the home page. QT's development language is C++ and QML. It can be developed and designed with various tools. The official IDE is QT Creator. It should be noted that the rabbit has not learned C++, only used VB.NET (this can even be traced back to junior high school hobbies, and I have always been a "no business" person, always hopelessly and "positive business" "There is little interest in knowledge." However, object-oriented is common. If you have used Visual Studio, you should be able to start development with familiarity with the syntax. First of all, you need to install QT. When the rabbit is doing development (Nokia has not completely cut QT), Nokia has made Qt SDK, and integrated Qt Lib, Qt Creator, etc., and the last version update should be QtSdk-offline-linux-x86- V1.2.1.run, as long as you double-click on Ubuntu to complete all installation work, very convenient. But now Nokia itself is difficult to protect, has long been unable to take care of Qt update work, Digia did not update the SDK action, and sealed the previous download address, so you can only download and install Qt Creator and Qt Lib separately, the specific configuration method please study . Two days of fast thunder can not be used, after a while I will upload a fast pass address, so that everyone can easily use the SDK to install. The rabbit has uploaded an installation package to the fast transfer, sharing time is limited, need to download it yourself: the latest version is 5.0 Beta, the rabbit is still using the stable version 4.8.3, after the installation is complete, enter Qt in Ubuntu navigation bar , choose to open Qt Creator.

ZedBoard Learning Notes (8) Bigger goals! Developing a graphical user interface under Linux

Let's start by writing a simple software (of course, HelloWorld). Create a new project and select the Qt GUI application.

ZedBoard Learning Notes (8) Bigger goals! Developing a graphical user interface under Linux

Enter the project name and path, and Qt Creator will automatically create a folder with the same name as the project.

ZedBoard Learning Notes (8) Bigger goals! Developing a graphical user interface under Linux

Select the target platform, here to run debugging under Ubuntu, so choose the desktop.

ZedBoard Learning Notes (8) Bigger goals! Developing a graphical user interface under Linux

Because a Qt GUI application is created here, Qt Creator will automatically create a window for the project. This window is encapsulated in the form of a class named HelloQT and the base class is QmainWindow.

ZedBoard Learning Notes (8) Bigger goals! Developing a graphical user interface under Linux

After the project is established, double-click helloqt.ui on the left to open the main window design interface.

ZedBoard Learning Notes (8) Bigger goals! Developing a graphical user interface under Linux

This interface is basically similar to Visual Studio. In the design interface, the left side is the control list, and the right side is the attribute list. However, the rabbit feels that the items covered in the attribute list are very limited compared with the VS. Many operations are executed by the code, and the automatic completion function is also very painful.

ZedBoard Learning Notes (8) Bigger goals! Developing a graphical user interface under Linux

In the design interface, add a Push Button and a Label to the target window (drag into the window), named ButtonHello and LabelHello, all we have to do is click on the Button to change the text content of the Label.

ZedBoard Learning Notes (8) Bigger goals! Developing a graphical user interface under Linux

Friends who have used VB.NET or C# should be aware that this function can only be implemented by inserting a Button_Clicked event. In QT, the corresponding event is the Signal Slot, which is used to pass the signal generated when the button is clicked. Right click on the Button and select Go to slot.

ZedBoard Learning Notes (8) Bigger goals! Developing a graphical user interface under Linux

Select clicked() for the signal type.

ZedBoard Learning Notes (8) Bigger goals! Developing a graphical user interface under Linux

The IDE will automatically switch to the code interface and enter the required function code for this slot. Another difference from VS is that many things can be modified in VS (such as this Text), but not in QT. The attribute is assigned, but a method is called to execute, so I am not used to it.

ZedBoard Learning Notes (8) Bigger goals! Developing a graphical user interface under Linux

The code is as follows, easy to understand, is to set the label text to "Hello QT!" through the setText method. Void HelloQT::on_ButtonHello_clicked(){ ui->LabelHello->setText("Hello QT!");}Save, click the Run button, Qt Creator will automatically compile and run the project.

ZedBoard Learning Notes (8) Bigger goals! Developing a graphical user interface under Linux

Ok, let's see the effect.

ZedBoard Learning Notes (8) Bigger goals! Developing a graphical user interface under Linux

The executable file generated by this project can be run directly under Ubuntu. Use the file command to view the application information. It is known that this is a program compiled for the x86 64-bit system. You want to run on the ZedBoard - whether it is the board or not. The demo system is still Linaro - it needs to be recompiled.

ZedBoard Learning Notes (8) Bigger goals! Developing a graphical user interface under Linux

Silicone Rubber Seal ring

Nantong Boxin Electronic Technology Co., Ltd. , https://www.ntbosen.com

This entry was posted in on