PyQt5 Tutorials
About Lesson

In this Python PyQt5 lesson we want to learn about Python PyQt5 QtQuick & QML, QtQuick is a feature of PyQt5 by using that you can separate your main design from logic. and QtQuick has its own language that is called QML. QML is Qt Markup Language, it is a language similar to JavaScript but it is not JavaScript. So when you want to work with QtQuick you need to create two files in Pycharm IDE, the first one is a QML file and the second one is a Python file.

 

 

Create a file with the .qml extension, i want to call it main.qml and add this code.

So in above code first we have our root element that is our window and in the window you can add your other widgets like Text, Image, InputField and etc. also we have some attributes for the window like width and height, window title and color of the window. 

 

 

Now it is time to load our qml file in python language.

 

 

At the top these are the imports.

 

 

You need to create the object for QApplication and QQmlApplicationEngine.

 

 

In here we have set the icon for the window, make sure that you have added an icon to your working directory.

 

 

 

This is for creating text, it is just a basic text with the color and font size.

 

 

 

Using this code you can add image in the window.

 

 

 

And this code is for adding TextInput

 

 

 

 

Run the complete code and this is the result.

PyQt5 QML - Working with QtQuick & QML in PyQt5
PyQt5 QML – Working with QtQuick & QML in PyQt5