Unsolved ScrollArea unresponsive after starting heavy task, unless all widgets have been scrolled into view
-
Hello!
I have encountered a problem when using a ScrollArea, causing it to freeze if you initiate a heavy task in a separate thread. However, if you manually scroll through the Scroll Area, from top to bottom, a couple of times prior to initiating the heavy task - the error does not occur. I have constructed a small demo:
# In the MainThread, the GUI and ScrollArea lives. # I have a separate QThread called TaskRunner, from which I manage the "heavy" tasks. # Starting the Task will spawn a new Thread, in which said task completes its work. # I have a QLabel labeled START - Upon pressing this label, it sends a signal to TaskRunner to start all the tasks.
The code can be found here.
What blows my mind is the following behaviour, I can't seem to find a logical explanation backed by the documentation :
ALT 1:
- Start Application --> Press Start Label --> Scrolling Freezes, basically unusable until the tasks (which are running in a separate thread) have finished
ALT 2:
- Start Application --> Manually scroll from top to bottom a couple of times --> Press Start Label --> Scrolling works smoothly, no freezes, lag or blocking
I have attatched the following videos in order to better illustrate: ALT 1 and ALT 2.
There has to be some form of loading taking place when you scroll the labels into view, but why does it freeze in ALT 1? I have tried to replicate the "Scrolling from top to bottom" by programatically changing the value of the ScrollBar - did not fix anything. I have also tried using
ensureWidgetVisible()
andblockSignals(True)
, sadly to no avail.So my question is, what is happening when you manually scroll through the entire area? Why does this make the ScrollArea responsive after initiating the heavy task? (Like in ALT 2). And finally, how can I solve this issue, without having to undergo the ritual of manually scrolling from top to bottom before starting the tasks?
I am very new to PyQT5, is my implementation of threads and Qthreads in the example attatched correct? Or does it perhaps have some major flaw causing this, seemingly, very odd problem?
Thank You!
-
please provide a Minimal reproducible example
-
@eyllanesc I attatched my code here
-
If a moderator reads me: Is it within the code that a user calls a member of the community as a troll? I think not since it is not a sign of respect. One may agree or disagree with the site's policies or the attitudes of others but that does not give anyone the right to insult
-
A do agree this discussion was just a misunderstanding and there is no need to get it heated. I'm locking the topic to avoid even more aggravation. If OP is still looking for help, feel free to open a new post and link to here.