PDA

View Full Version : Area for detachable QDialogs within QGridLayout



nicole.cpp
11th April 2014, 20:00
I have a QMainWindow with a QGridLayout of various widgets that looks like the attached png.

10279

I will have various little input dialogs that come up at different times, and I want them to appear in certain cell of the layout (bright cyan area below purple tab widget in picture). They would show up in this cell by default but should be detachable and able to be moved around as desired (just like a regular, stray QDialog).

What would be the best way to go about this?

I tried using a QDockWidget and just adding it right into the grid layout, but it seems I cannot un-dock it and move it around, even with a call to setFeatures that should allow this freedom.

The addDockWidget function allows the desired movement, but this won't let me incorporate the dock area within the grid; it just puts the dock widget on, e.g., one side of the entire main window.

zaphod.b
12th April 2014, 10:39
QMainWindow::AllowNestedDocks might do what you need.

Mind, however, that the main window layout is not a grid layout, with all pros and cons.

nicole.cpp
14th April 2014, 18:10
Hmm...would it work if the main window had a nested set of QHBox/QVBoxLayouts to imitate the grid? This wouldn't be ideal, though, so maybe I just need an alternative to QDockWidget in general.

Perhaps something else floatable, like a QToolBar that gets the appropriate "dialog" features shown on it at the appropriate times?

nicole.cpp
15th April 2014, 17:02
Somewhat of a work-around: I put the tab widget itself into a DockWidget, then made a dock widget as before for the dialogs and put them both in the same DockWidgetArea of the main window. This stacks them nicely (though it does mean that the upper toolbars and text edit no longer go all the way across) and is pretty close to the desired result.

To really go all-out, I suppose I could try docking the upper toolbars as well, which would be flexible, but for now, this will do!