Course Content
PyQt5 Basics – Installation Process, Qt Designer Intro
In this part we are going to talk about some basics functionalities in PyQt5, we go through installation process, creating QPushButton, Signals and working with Qt Designer.
0/4
PyQt5 Tutorials
About Lesson

In the third lesson of PyQt5  we are going to learn about PyQt5 Working With Signal And Slots.  Signal and Slots are used for communication between some objects. a Signal is emitted when a particular event occurs, and a Slot is called when its connected signal is emitted. so now we are going to create an example of PyQt5 Signal and Slots.

 

 

These are some imports that we need for this lesson, basically we are using the codes from the previous lesson as we have created our QPushButton with colors and styles.

 

 

Using this code we can set the geometry for the window. you need to add the x, y position of the window, width and height of the window.

 

 

For setting the window title you need to use this line of code.

 

 

If you want to add an icon in your window, you can use this code, make sure that you have already added an icon in your working directory.

 

 

So you can create pyqt5 buttons by creating the object of QPushButton.

 

 

For button there is a signal that is called clicked signal, so you need to connect this clicked signal with method that you want to create. basically by clicking the button we want to just print the text in the console.

 

 

So you can see we have connected the clicked signal of the button with the clicked_btn() method that we are going to create.

 

 

This is just a simple method or slot that we have already connected.

 

 

So now this is the complete code for PyQt5 Working With Signal And Slots

 

 

 

Run the complete code and this is the result.

PyQt5 Working With Signal And Slots
PyQt5 Working With Signal And Slots
Thank you for visiting my website! If you enjoyed the free courses, please consider supporting my works on Patreon.
Exercise Files
No Attachment Found
No Attachment Found