Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Dockarea within own widget
QtWS25 Last Chance

Dockarea within own widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 4 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Perdrix
    wrote on 8 Oct 2022, 15:28 last edited by Perdrix 10 Aug 2022, 15:30
    #1

    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.

    74c4d41a-db16-4934-ab89-bb51db92a460-image.png

    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 ...

    J 1 Reply Last reply 8 Oct 2022, 15:36
    0
    • P Perdrix
      8 Oct 2022, 15:28

      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.

      74c4d41a-db16-4934-ab89-bb51db92a460-image.png

      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 ...

      J Offline
      J Offline
      JonB
      wrote on 8 Oct 2022, 15:36 last edited by
      #2

      @Perdrix said in Dockarea within own widget:

      but how do I create an area within my widget that can contain that dock widget?

      QDockWidget Class

      The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-level window on the desktop.

      ?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 8 Oct 2022, 15:36 last edited by SGaist 10 Aug 2022, 15:39
        #3

        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.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Perdrix
          wrote on 9 Oct 2022, 01:15 last edited by
          #4

          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

          M 1 Reply Last reply 9 Oct 2022, 11:56
          0
          • P Perdrix
            9 Oct 2022, 01:15

            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

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 9 Oct 2022, 11:56 last edited by
            #5

            @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.

            1 Reply Last reply
            1
            • P Offline
              P Offline
              Perdrix
              wrote on 9 Oct 2022, 12:39 last edited by
              #6

              Nice trick!!! Thank you

              1 Reply Last reply
              0
              • P Offline
                P Offline
                Perdrix
                wrote on 9 Oct 2022, 12:53 last edited by Perdrix 10 Sept 2022, 13:02
                #7

                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:

                366dd271-2bbe-4ce1-9ada-b5104b95e06f-image.png

                Thanks
                D.

                M 1 Reply Last reply 9 Oct 2022, 16:39
                0
                • P Perdrix
                  9 Oct 2022, 12:53

                  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:

                  366dd271-2bbe-4ce1-9ada-b5104b95e06f-image.png

                  Thanks
                  D.

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 9 Oct 2022, 16:39 last edited by
                  #8

                  @Perdrix

                  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)

                  alt text

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    Perdrix
                    wrote on 9 Oct 2022, 18:19 last edited by Perdrix 10 Sept 2022, 18:21
                    #9

                    Does that mainwindow.h have to be created by me ... It's odd that Qt Designer recognised MainWindow immediately as something it understood!

                    M 1 Reply Last reply 9 Oct 2022, 18:43
                    0
                    • P Perdrix
                      9 Oct 2022, 18:19

                      Does that mainwindow.h have to be created by me ... It's odd that Qt Designer recognised MainWindow immediately as something it understood!

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 9 Oct 2022, 18:43 last edited by
                      #10

                      @Perdrix

                      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.

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        Perdrix
                        wrote on 10 Oct 2022, 07:03 last edited by Perdrix 10 Oct 2022, 09:59
                        #11

                        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 :(

                        2d847e09-a76c-45b3-aa58-78504b740b70-image.png

                        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.

                        0a3aa71a-3d69-4a1f-914e-6a8162d6f31d-image.png

                        I'm having the identical problem with the DockWidget:

                        70c50dcf-b07c-4a4b-ad66-8a13c5bbd2cb-image.png

                        1 Reply Last reply
                        0

                        7/11

                        9 Oct 2022, 12:53

                        • Login

                        • Login or register to search.
                        7 out of 11
                        • First post
                          7/11
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved