Re: how to create own event?
What does it mean "there is a real button" ? Is it a hardware button ?
Re: how to create own event?
Quote:
i need to create event like pushButton.clicked.connect()
This is not an "event".
Are you saying that you have a real, physical button that a human pushes with her finger, and you want to detect that press with your program? I assume you are still using a RasPi as you mentioned in your previous post.
First, you need to use the functions of python on the RasPi to detect the physical state change of the button. There are many examples for how to detect contact closures using the input pins of the Pi. I am not sure if you need to monitor the button state continuously or whether the Pi can send an interrupt to your program when the state changes. If you cannot use an interrupt, then I would suggest you use a QTimer to check the button every 100 ms or so in a slot connected to the QTimer's timeout() signal. If you write a loop to continually check the state, then your program will freeze in the loop.
You should implement the code for responding to the button press in a class derived from QObject. Classes based on QObject have the ability to send signals. In your class, you should implement a signal that will be emitted when the button changes state. You should also be able to find examples of how to implement a custom signal in your PyQt documentation. You can then connect this signal to any other part of your program that needs to know when the button has been pressed.
Re: how to create own event?
Thank you so much,sir. Thats working.