[Interest] Struggles with dock widgets

Sean Murphy Sean.M.Murphy at us.kbr.com
Mon Jan 29 16:50:10 CET 2024


I've got two different questions regarding working with dock widgets:

Question 1: Is there a way to combine dock widgets and non-dockable widgets within the same dock area region? For our main window, we have 3 widgets (A, B, & C) that we want to have initially in a column on the left side of the main window (i.e. the Qt::LeftDockWidgetArea), and then a large central widget taking up the rest of the window. Widget A should NOT be able to be undocked/moved. Widgets B & C should be. I really want A to just be a normal widget, and B & C should be wrapped in a QDockWidget, but I don't see a way to tell the docking system that it doesn't get to use the entire left dock widget area from top to bottom, and instead that I'd like to reserve the upper left corner for a widget A and only allow B & C to dock on the left side below A. The only thing I've found so far is that I can wrap widget A in a QDockWidget, but set it's dock widget features to QDockWidget::NoDockWidgetFeatures and that at least puts it in the column and prevents it from being undocked.

I can live with that, but is that the "right way" to accomplish what I'm trying to do?



Question 2: Is there way to control the initial position of the three dock widgets? In this application's developmental history, we already had widgets B & C by themselves in the left dock area. My current task is adding widget A to the mix, but I want it to be always in the application's upper left corner. When I first attempted to add it to the .ui file via drag and drop in QtDesigner, QtDesigner would only put it below dock widgets B & C. I then closed the .ui file in QtDesigner, opened it in a text editor and rearranged the XML to put widget A first, then B, then C and saved it. Now when I open this modified .ui file in QtDesigner it visually looks like how I want - A, B, then C from top to bottom. But when I then compile and run the application, the dock widgets are laid out as B, C, then A from top to bottom. I can't seem to figure out what is causing the widgets to reorder? When I look at the ui_mainwindow.h file, the widgets are instantiated in the desired order (A, B, C) and the three MainWindow->addDockWidget() calls are in the correct order as well (A, B, C), but for some reason when displayed I see B, C, then A.

Sean






This e-mail, including any attached files, may contain confidential information, privileged information and/or trade secrets for the sole use of the intended recipient. Any review, use, distribution, or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.


More information about the Interest mailing list