Dockarea within own widget
-
wrote on 8 Oct 2022, 15:28 last edited by Perdrix 10 Aug 2022, 15:30
I want to be able to "tear off" part of a widget which is currently a grid layout containing a label, tabbed widget and a tableview.
I imagine that I could place all of those inside a dock widget, but how do I create an area within my widget that can contain that dock widget? There doesn't seem to be anything I can find that will accept dock widgets being dropped on them ...
-
I want to be able to "tear off" part of a widget which is currently a grid layout containing a label, tabbed widget and a tableview.
I imagine that I could place all of those inside a dock widget, but how do I create an area within my widget that can contain that dock widget? There doesn't seem to be anything I can find that will accept dock widgets being dropped on them ...
wrote on 8 Oct 2022, 15:36 last edited by@Perdrix said in Dockarea within own widget:
but how do I create an area within my widget that can contain that dock widget?
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-level window on the desktop.
?
-
Lifetime Qt Championwrote on 8 Oct 2022, 15:36 last edited by SGaist 10 Aug 2022, 15:39
Hi,
Dock area is only available in QMainWindow.
Are you using one or do you want your widget to act like one ?
If the later, there are projects providing docking like KDAB's KDDockWidgets.
-
wrote on 9 Oct 2022, 01:15 last edited by
Yes I'm using a QMainWindow, but I don't want this to be docked in any of its dock areas in the initial case, but in a dock area within my own widget.
David
-
Yes I'm using a QMainWindow, but I don't want this to be docked in any of its dock areas in the initial case, but in a dock area within my own widget.
David
@Perdrix
Hi
you can add a QMainWindow to your widget and use that for docking.
Despite its name, you can use as many MainWindows as you like and
it will act like a standard widget, just with ability to dock. -
wrote on 9 Oct 2022, 12:39 last edited by
Nice trick!!! Thank you
-
wrote on 9 Oct 2022, 12:53 last edited by Perdrix 10 Sept 2022, 13:02
-
How to persuade Qt Designer to insert a QMainWindow into my widget? I tried adding a QWidget and tried to promote it to a QMainWindow and Designer complained:
Thanks
D.Hi
You must have a child of a QMainWindow class to point it to.So for a std. Qt project you can point it to
MainWindow. (it inherits QMainWindow) -
wrote on 9 Oct 2022, 18:19 last edited by Perdrix 10 Sept 2022, 18:21
Does that mainwindow.h have to be created by me ... It's odd that Qt Designer recognised MainWindow immediately as something it understood!
-
Does that mainwindow.h have to be created by me ... It's odd that Qt Designer recognised MainWindow immediately as something it understood!
Well yes, if you mean it must exists, as it is added to the generated ui_ file as a normal include so if its "fake" then later it will complain about it.
I was also kinda surprised it said that for QMainWindow.
-
wrote on 10 Oct 2022, 07:03 last edited by Perdrix 10 Oct 2022, 09:59
I managed to get that concept working but creating a main window form wouldn't let me specify the class name for the main window or the header file, so I manually edited the ui file to add:
<customwidgets> <customwidget> <class>DSS::BayWindow</class> <extends>QMainWindow</extends> <header>baywindow.h</header> <container>1</container> </customwidget> </customwidgets>
and changed the start to look like this:
<class>StackingDlg</class> <widget class="DSS::BayWindow" name="StackingDlg">
Which has got me started! I have however hit a small problem that I'm sure is obvious to you mavens! I've so far failed to get the contents of the central widget to expand to fill it :(
What have I missed - the picture control (lower horizontal layout) is set to Expanding, Expanding so I though that would force the issue, but it doesn't seem to have done it.
I'm having the identical problem with the DockWidget:
2/11