Tag Archives: qt

How to develop GUI Application with PyQt (python Qt)

There are two main methods for developing GUI application with qt:
1) Adding all widgets in your code (your cpp or python code)
2) Creating qt UI files, adding widgets there and load everything into your application.

1)Adding all widgets in your code

Here is the snippet for adding all widgets and their slots in code:

2) Creating qt UI files, adding widgets there and load everything into your application

Now let’s do what we have done in the first method in a UI file and load it. First, create a text file and put the followings in it and save it as “mainwindow.ui”


Now call it in your python file like this:

The results should be the same as what you got in the first method.

Adding Qt UI files to your CMake

Qt uses qmake  to generate classes from UI files and compile everything in the project, luckily there are some macros in CMake that allows you to bring everything into your CMake and build everything there, here is what you need to do:

you can find the full project at my Github