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. Can I save/restore the current state (pos/size...) of a QDockWidget?
QtWS25 Last Chance

Can I save/restore the current state (pos/size...) of a QDockWidget?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 4.8k 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.
  • A Offline
    A Offline
    ahuarte
    wrote on 3 Aug 2016, 11:32 last edited by
    #1

    Hi, I would like to save/restore the position, size and docking-window-state of a group of QDockWidgets in a QApplication.

    The state of these QDockWidgets must not be saved in the global QSettings of the application, they must be saved in other project document (It is a XML-user document).

    I see the methods to use for all windows of the application:

    • void QApplication::saveState(QSessionManager & manager)
    • void QApplication::restoreState(QSessionManager & manager)

    But I dont know how to save or read the docking-window-state of each QDockWidget instance.
    How do I do it?

    Thanks in advance

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 3 Aug 2016, 11:55 last edited by
      #2

      Hi and welcome to devnet,

      That's not the role of these two method.

      You have:

      • QMainWindow::saveState
      • QMainWindow::restoreState
      • QMainWindow::saveGeometry
      • QMainWindow::restoreGeometry

      As for the QDockWidget, each must have a unique object name. It's all explained in the documentation of these methods.

      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
      • A Offline
        A Offline
        ahuarte
        wrote on 3 Aug 2016, 12:27 last edited by
        #3

        Hi, thanks for your reply, I dont want to save in the application QSettings file, but in a xml-node of another file, and only a group of QDockWidgets.

        Is it possible?

        R 1 Reply Last reply 3 Aug 2016, 13:33
        0
        • A ahuarte
          3 Aug 2016, 12:27

          Hi, thanks for your reply, I dont want to save in the application QSettings file, but in a xml-node of another file, and only a group of QDockWidgets.

          Is it possible?

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 3 Aug 2016, 13:33 last edited by
          #4

          @ahuarte said:

          I dont want to save in the application QSettings file, but in a xml-node of another file

          You can do whatever you want with the returned QByteArray.

          and only a group of QDockWidgets.

          this is not possible.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 3 Aug 2016, 13:56 last edited by
            #5

            For the group handling, you can try to restore the state of the QMainWindow before you create the QDockWidgets and then use restoreDockWidget on your group of interest.

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

            K 1 Reply Last reply 3 Aug 2016, 14:00
            0
            • S SGaist
              3 Aug 2016, 13:56

              For the group handling, you can try to restore the state of the QMainWindow before you create the QDockWidgets and then use restoreDockWidget on your group of interest.

              K Offline
              K Offline
              kshegunov
              Moderators
              wrote on 3 Aug 2016, 14:00 last edited by
              #6

              Also be aware of QTBUG-16252.

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              0
              • A Offline
                A Offline
                ahuarte
                wrote on 3 Aug 2016, 15:04 last edited by ahuarte 8 Mar 2016, 21:34
                #7

                Hi, thanks to all for your advices!

                I will manage the "x/y/width/height" properties of the QDockWidgets and I will try to save and to restore the dock-state of each window "by hand".

                Kind regards

                1 Reply Last reply
                0

                6/7

                3 Aug 2016, 14:00

                • Login

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