Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt QDockWidget(floating) minimizes when my MainWindow minimizes

Tags:

c++

qt

How can I minimize my QMainWindow without also minimizing my QDockWidget that I have undocked and is floating? What I want to do, is take a small window of my GUI to monitor the rest of the MainWindow. The MainWindow does not to be on the screen, all I want to see is the DockWidget while it is floating.

like image 804
JonnyCplusplus Avatar asked Oct 10 '22 18:10

JonnyCplusplus


1 Answers

The floating window is almost certainly being minimized when your main window is minimized because the main window owns the child window. Or in other words, the floating window is a child of the main window. And a child window cannot be visible when its owner window is minimized.

The solution obviously is to break the ownership relationship between your floating window and the main window. That will probably also require that you change the type of window that your floating window represents. I'm guessing that a QDockWidget class implements a floating tool palette or other form of pop-up window. In order to have a standalone window, you'll need to create an overlapped window.

Read more about the various types of windows here, at least assuming that you're using Windows.
I imagine that it's a similar state of affairs for the other target operating systems.

On Windows in particular, someone might suggest that you make the floating window a child of the desktop window, but let me take this opportunity to strongly advise you against doing that. For a more nuanced discussion, see Raymond Chen's blog post on the subject.

like image 132
Cody Gray Avatar answered Oct 24 '22 23:10

Cody Gray