PyQt5 Tutorials
About Lesson

In this Python PyQt5 lesson we want to learn about Python PyQt5 QDial , so the QDial class provides a rounded range control (like a speedometer or potentiometer). QDial is used when the user needs to control a value within a program-definable range, and the range either wraps around (typically, 0.. 359 degrees) or the dialog layout needs a square widget.

 

Now open your Qt Designer,  you can just write pyqt5designer in your terminal, after opening the Qt Designer you need to create Widget window. now we add widgets in Qt Designer.

  • Add a VBoxLayout in the Qt Designer
  • Add a QDial and QLabel widgets in the VBoxLayout

 

You can right click on the dial and choose Change Stylesheet and add this css style.

 

 

 

This is the design.

PyQt5 QDial Design
PyQt5 QDial Design

 

 

After completing the design you need to save the .ui file, iam going to name it diald.ui, now copy the file and paste it in the Scripts folder of your Python installation, because we want to convert our ui file in to python file and for converting you need to use pyuic5 module. pyuic5 module is located in the Scripts folder of your Python installation, run this command for converting in your terminal.

 

 

And this is the converted code also we have added our valueChanged() signal with the method that we want to connect.

 

 

 

This is the method that we have already connected with the clicked signal of qdial class. firs we need to get the value from the dial class and after that we set the value in our label.

 

 

 

Run the code and this will be the result.

PyQt5 Dial - Working with QDial in PyQt5
PyQt5 Dial – Working with QDial in PyQt

 

 

 

Creating PyQt5 QDial using coding 

OK now we want to create our pyqt5 dial using coding, in the previous part we have used Qt Designer, in here we are not going to use Qt Designer. this is the complete source code.

 

 

These are our window requirements like window title, window icon, width and height of the window, x and y position of the window.

 

 

So you can use QDial class object for creating dial in Python PyQt5.

 

 

In here we have set the minimum and maximum value of QDial class. also we have added stylesheet for our dial application.

 

 

This is the valueChanged() signal that is connected with the dial_changed() method.

 

 

This is the method that we have already connected with the clicked signal of dial. so in this method first we need to get the item value from PyQt5 QDial and after that we set the value in pyqt label.

 

 

 

Run the complete code and this is the result.

Working with QDial in PyQt5
Working with QDial in PyQt