Simple GUI with QT

by Spiros Kaftanis

Qt is a cross-platform application framework that is widely used for developing application software with a graphical user interface (GUI) (in which cases Qt is classified as a widget toolkit), and also used for developing non-GUI programs such as command-line tools and consoles for servers.

Qt uses standard C++ but makes extensive use of a special code generator (called the Meta Object Compiler, or moc) together with several macros to enrich the language. Qt can also be used in several other programming languages via language bindings. It runs on the major desktop platforms and some of the mobile platforms. It has extensive internationalization support. Non-GUI features include SQL database access, XML parsing, thread management, network support, and a unified cross-platform application programming interface (API) for file handling.

Qt is available under a commercial license, GPL v3 and LGPL v2. All editions support many compilers, including the GCC C++ compiler and the Visual Studio suite.

You can download it from here. You also need some development packages if you are in Linux. You can find it easily in google. And of course you need a C++ compiler.

Open Qt Creator and start a new project.

There are many choices here, but for now you can select Qt Widget Application.

Select a name and the save location and your project wll be ready.

In the left side you can see all the files of the project.

Click on .ui file. This is the designer. Here, you can create a GUI with just drag and drop! A good tutorial about Qt is in TheNewBoston.

In the picture below you can see InstallerCreator!

Designer created an XML layout so you don’t need to write the GUI programmaticaly.  If you want to run bash script when the button clicked select “Go to Slot” choice in the right click of a button. Select “clicked” or something else.

Creating a GUI with Qt

GUI = Graphics User Interface

Qt is a cross-platform application framework that is widely used for developing application software with a graphical user interface (GUI) (in which cases Qt is classified as a widget toolkit), and also used for developing non-GUI programs such as command-line tools and consoles for servers.

Qt uses standard C++ but makes extensive use of a special code generator (called the Meta Object Compiler, or moc) together with several macros to enrich the language. Qt can also be used in several other programming languages via language bindings. It runs on the major desktop platforms and some of the mobile platforms. It has extensive internationalization support. Non-GUI features include SQL database access, XML parsing, thread management, network support, and a unified cross-platform application programming interface (API) for file handling.

Qt is available under a commercial license, GPL v3 and LGPL v2. All editions support many compilers, including the GCC C++ compiler and the Visual Studio suite.

You can download it from here. You also need some development packages if you are in Linux. You can find it easily in google. And of course you need a C++ compiler.

Open Qt Creator and start a new project.

There are many choices here, but for now you can select Qt Widget Application.

Select a name and the save location and your project wll be ready.

In the left side you can see all the files of the project.

Click on .ui file. This is the designer. Here, you can create a GUI with just drag and drop! A good tutorial about Qt is in TheNewBoston.

In the picture below you can see InstallerCreator!

Designer created an XML layout so you don’t need to write the GUI programmaticaly.  If you want to run bash script when the button clicked select “Go to Slot” choice in the right click of a button. Select “clicked” or something else.

This, will guide you to the .cpp file. Here you can edit the listener function you just created. If you want to run a sctipt use system() function with the right  command as a string.

Now you are ready to build the application.

With the terminal go to the folder where you saved the project and give:

qmake-qt4 -project

After that, open .pro file and add thease lines:

QT += core gui

QT += widgets

after TAGET.

Then run

qmake-qt4

and finally

make

If all went well you will have the executive that is capable to run in every computer with the same bits architecture.

Show Your Love

Studying in Computer Engineering & Informatics Department. Member of the fedora community. Interested in mobile apps and machine learning.

2 Comments on “Simple GUI with QT

Leave a Reply

Your email address will not be published. Required fields are marked *