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. How to get the relationship between two QDockWidget?
Forum Update on Monday, May 27th 2025

How to get the relationship between two QDockWidget?

Scheduled Pinned Locked Moved General and Desktop
16 Posts 4 Posters 4.7k 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.
  • Y Offline
    Y Offline
    yunxiaodong
    wrote on last edited by
    #1

    In QMainWindow, I add two QDockWidget.I use the function

    @
    QMainWindow::splitDockWidget ( QDockWidget * first, QDockWidget * second, Qt::Orientation orientation )
    @

    set the relationship of this two QDockWidget. But, how to get the relationship of this two QDockWidget, how should I do ?

    I love peace.

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      bq. But, how to get the relationship of this two QDockWidget, how should I do ?

      what kind of relationship do you want?

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        yunxiaodong
        wrote on last edited by
        #3

        relationship like this: Qt::Horizontal,Qt::Vertical. for example: one QDockWidget is on the rightside(Horizontal) of another.
        or one QDockWidget is on the topside(Vertical) of another.

        I love peace.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          If you don't mind me asking: what do you need this for? What do you want to achieve?

          1 Reply Last reply
          0
          • Y Offline
            Y Offline
            yunxiaodong
            wrote on last edited by
            #5

            well,my purpose is that when my application closing,i save all QDockwidget's state and achieve it to xml,then the next time application startup,i read the xml to get the state of all QDockwidget to restore the state.

            I love peace.

            1 Reply Last reply
            0
            • F Offline
              F Offline
              Franzk
              wrote on last edited by
              #6

              Use "QMainWindow::saveState()":http://doc.trolltech.com/latest/qmainwindow.html#saveState and "QMainWindow::restoreState()":http://doc.trolltech.com/latest/qmainwindow.html#restoreState for that sorta thing.

              "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                [quote author="Franzk" date="1313503030"]Use "QMainWindow::saveState()":http://doc.trolltech.com/latest/qmainwindow.html#saveState and "QMainWindow::restoreState()":http://doc.trolltech.com/latest/qmainwindow.html#restoreState for that sorta thing.[/quote]

                Indeed: that's why I asked :-)

                1 Reply Last reply
                0
                • Y Offline
                  Y Offline
                  yunxiaodong
                  wrote on last edited by
                  #8

                  I make a layout manager which can modify the achieved xml .This layout manager is for Users,Users can use manager layout QDockwidgets by their way. Then the application can layout QDockwidgets according the achieved xml.

                  I love peace.

                  1 Reply Last reply
                  0
                  • Y Offline
                    Y Offline
                    yunxiaodong
                    wrote on last edited by
                    #9

                    QMainWindow::saveState() and restore function cant fit.

                    I love peace.

                    1 Reply Last reply
                    0
                    • Y Offline
                      Y Offline
                      yunxiaodong
                      wrote on last edited by
                      #10

                      may be i have a bad english expression,i should study hard.

                      I love peace.

                      1 Reply Last reply
                      0
                      • F Offline
                        F Offline
                        Franzk
                        wrote on last edited by
                        #11

                        As far as I know, saveState()/restoreState() is the only way of accessing this. Why do you want to manage this from a layout manager when QMainWindow does it for you already?

                        "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                        http://www.catb.org/~esr/faqs/smart-questions.html

                        1 Reply Last reply
                        0
                        • Y Offline
                          Y Offline
                          yunxiaodong
                          wrote on last edited by
                          #12

                          now, i can save QToolBar,QMenu state and restore them well,but cant restore QDockwidget well only.
                          For different users or industry, i support application with different layout.

                          I love peace.

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            andre
                            wrote on last edited by
                            #13

                            If all else fails: the sources of Qt are available to you. Check how saveState() and restoreState() are implemented, and perhaps you'll find something you can use. You might need to use undocumented or even expose private functionality to pull it off that way. Perhaps even a modification of Qt itself is needed. If you implement that nicely, you could try to have that merged in as a patch (if you can give a good use case for it).

                            1 Reply Last reply
                            0
                            • Y Offline
                              Y Offline
                              yunxiaodong
                              wrote on last edited by
                              #14

                              Good idea. Actually I have saw the saveState() and restoreState() source code for several times. It is based on too much Qt's private implemention. It use many classes(not api) which derived from QLayout to implement this.I will continue to study.

                              I love peace.

                              1 Reply Last reply
                              0
                              • Y Offline
                                Y Offline
                                yunxiaodong
                                wrote on last edited by
                                #15

                                ok

                                I love peace.

                                1 Reply Last reply
                                0
                                • A Offline
                                  A Offline
                                  andre
                                  wrote on last edited by
                                  #16

                                  Please use the edit option next to your post to make spelling corrections or additions instead of making new posts.

                                  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