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
Forum Updated to NodeBB v4.3 + New Features

Dockarea within own widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 4 Posters 1.5k Views 3 Watching
  • 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by Perdrix
    #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 ...

    JonBJ 1 Reply Last reply
    0
    • PerdrixP Perdrix

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

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on 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
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by SGaist
        #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
        • PerdrixP Offline
          PerdrixP Offline
          Perdrix
          wrote on 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

          mrjjM 1 Reply Last reply
          0
          • PerdrixP Perdrix

            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

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on 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
            • PerdrixP Offline
              PerdrixP Offline
              Perdrix
              wrote on last edited by
              #6

              Nice trick!!! Thank you

              1 Reply Last reply
              0
              • PerdrixP Offline
                PerdrixP Offline
                Perdrix
                wrote on last edited by Perdrix
                #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.

                mrjjM 1 Reply Last reply
                0
                • PerdrixP Perdrix

                  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.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 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
                  • PerdrixP Offline
                    PerdrixP Offline
                    Perdrix
                    wrote on last edited by Perdrix
                    #9

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

                    mrjjM 1 Reply Last reply
                    0
                    • PerdrixP Perdrix

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

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 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
                      • PerdrixP Offline
                        PerdrixP Offline
                        Perdrix
                        wrote on last edited by Perdrix
                        #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

                        • Login

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