showNormal() makes the app stuck
-
Hi,
I am trying to open the main window after minimising it using showNormal().
But on debugging my app gets stuck at this command and shows not responding. What could be the reason for this?Hi,
Are you using PySide 6 / PyQt 6 ?
Which version ?
On which OS ?Please provide a minimal script that shows that behaviour.
-
Hi,
Are you using PySide 6 / PyQt 6 ?
Which version ?
On which OS ?Please provide a minimal script that shows that behaviour.
@SGaist i am using PyQt5 on windows 10 with python 3.8.10.
code snippet-
(this is inside mainwindow class. As of now, the main waindow [self] is minimized)
if self.checkbox.isChecked():
self.showNormal()The code gets stuck at the line above and the screen becomes blank and says not responding
-
@SGaist i am using PyQt5 on windows 10 with python 3.8.10.
code snippet-
(this is inside mainwindow class. As of now, the main waindow [self] is minimized)
if self.checkbox.isChecked():
self.showNormal()The code gets stuck at the line above and the screen becomes blank and says not responding
Please provide a minimal complete scrip to reproduce your issue.
Also, which version of PyQt5 ?
-
Please provide a minimal complete scrip to reproduce your issue.
Also, which version of PyQt5 ?
@SGaist i am sorry i am not able to make a minimal reproduction. The error happens sometimes (not always) and not in the case of a simple code. Do you think too many threads can cause the showNormal() function to get stuck? I have used threading in my app.
PS: I had another window open alongside the main window. And then i gave the command to showNormal on the main window. Maybe thats causing an issue?
-
@SGaist i am sorry i am not able to make a minimal reproduction. The error happens sometimes (not always) and not in the case of a simple code. Do you think too many threads can cause the showNormal() function to get stuck? I have used threading in my app.
PS: I had another window open alongside the main window. And then i gave the command to showNormal on the main window. Maybe thats causing an issue?
-
@Prabhav I tried otherwindow.close() before doing self.showNormal() and not it seems to work!! But i have no idea how closing the second window has an impact on opening the first window. Do you have any idea about why this might be happening?
Without your code, no I can't say. You might doing something blocking the event loop.
-
@SGaist i am sorry i am not able to make a minimal reproduction. The error happens sometimes (not always) and not in the case of a simple code. Do you think too many threads can cause the showNormal() function to get stuck? I have used threading in my app.
PS: I had another window open alongside the main window. And then i gave the command to showNormal on the main window. Maybe thats causing an issue?
@Prabhav
As @SGaist says. When you have an issue which you cannot reproduce in a minimal example and only happens in some complex code you know that it is going to have something to do with that code and that nobody will be to answer without seeing it!It is a "shame" if you have many threads, that's often not needed in a Qt application, may be overused by beginners and is a frequent source of errors. "Intermittent" behaviour can often happen in thread cases, where the order of operations may vary over time.
The first thing to make sure is that no code in your threads accesses (read or write) anything in the UI. That is not allowed in Qt and leads to undefined behaviour. For example (just an example) if the two lines of code you show are executed from a thread (i.e. called directly, not via a signal which the main window has attached a slot to) that would be a no-no. But even if this call is made correctly, if anything else infringes the rule all bets are off for the state of the UI.