Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Does Dragging Floating QWidgets Block Main GUI Thread?
polluxpolaris last edited by polluxpolaris
While dragging floating QDockWidgets or QDialog around the screen, the main GUI thread seems to be blocked and possibly other threads as well. Is this expected behavior? Is there any way I can keep floating/dragging QWidgets from blocking other threads?
- I create a docked QDockWidget *textWidget with a QTextEdit that has text constantly written to it..
- I create a separate QDockWidget *floatWidget.
- At runtime I undock floatWidget and drag it around the screen without releasing the left mouse button.
- textWidget keeps updating with new text while floatWidget is being dragged.
- I release the left mouse button so floatWidget is floating.
- I click and drag floatWidget around the screen without releasing the left mouse button.
- textWidget stops updating while left mouse button is held down.
- I release the left mouse button and leave floatWidget floating.
- textWidget resumes text updates.
It seems like once a QWidget starts floating, it will then block other threads while being dragged until it stops being dragged or is docked.
Is there any way I can keep floating/dragging QWidgets from blocking other threads?
I tried installEventFilter() to intercept all QDialog events in case some move event was flooding the thread.
I tried setting QDialog parent as MainWindow as well as MainWindow->parentWidget().
I tried placing QDialog in it's own QThread.
I tried setMouseTracking(false).
I tried all of the different setWindowsFlags()
@polluxpolaris One note: there is only one GUI thread where all widgets are living. Your problem is not related to multithreading. And you should never use GUI classes in non GUI thread! All GUI classes (widgets, dialogs,...) must be in the same thread.
To your question: I assume it is expected behaviour, but I don't know for sure, maybe anybody else knows.
polluxpolaris last edited by
@jsulm You are correct. I updated my question to reference specifically the main gui thread. I've never used a GUI class in a non-GUI thread, I was just trying anything I could to see if I could keep the dragged QWidget from blocking the GUI thread.