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. I can't set state for QMainWindow
Qt 6.11 is out! See what's new in the release blog

I can't set state for QMainWindow

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 1.0k 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.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by Mikeeeeee
    #1

    Hi!
    I have 2 QMainWindow in my program. For first QMainWindow I can set state for QMainWindow, but for second QMainWindow restoreState() not work. Second QMainWindow at the start I create 2 QDockWidget. How save state 2 QDockWidget from from second QMainWindow?

    jsulmJ 1 Reply Last reply
    0
    • M Mikeeeeee

      Hi!
      I have 2 QMainWindow in my program. For first QMainWindow I can set state for QMainWindow, but for second QMainWindow restoreState() not work. Second QMainWindow at the start I create 2 QDockWidget. How save state 2 QDockWidget from from second QMainWindow?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Mikeeeeee How do you store the state of both QMainWindow? And why do you have two QMainWindow in your app?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mikeeeeee
        wrote on last edited by
        #3

        @jsulm said in I can't set state for QMainWindow:

        How do you store the state of both QMainWindow? And why do you have two QMainWindow in your app?

        I hove 2 QMainWindow becouse me need use QDockWidget in centr my window. I wont use QMainWindow::saveState() and QMainWindow::restoreState(). For first QMainWindow it's work.

        jsulmJ 1 Reply Last reply
        0
        • M Mikeeeeee

          @jsulm said in I can't set state for QMainWindow:

          How do you store the state of both QMainWindow? And why do you have two QMainWindow in your app?

          I hove 2 QMainWindow becouse me need use QDockWidget in centr my window. I wont use QMainWindow::saveState() and QMainWindow::restoreState(). For first QMainWindow it's work.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Mikeeeeee Did you see this in the documentation:
          "The objectName property is used to identify each QToolBar and QDockWidget. You should make sure that this property is unique for each QToolBar and QDockWidget you add to the QMainWindow"?
          https://doc.qt.io/qt-5/qmainwindow.html#saveState
          Did you make sure your QToolBars and QDockWidgets have unique names?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • M Offline
            M Offline
            Mikeeeeee
            wrote on last edited by
            #5

            They are unique, otherwise I wouldn't be able to add them.

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Mikeeeeee said in I can't set state for QMainWindow:

              I wouldn't be able to add them.

              ?

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Mikeeeeee
                wrote on last edited by
                #7

                The name of each object is unique.

                jsulmJ 1 Reply Last reply
                0
                • M Mikeeeeee

                  The name of each object is unique.

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Mikeeeeee To make sure we are talking about same thing: I'm talking about https://doc.qt.io/qt-5/qobject.html#objectName-prop, not variable names.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  2
                  • M Offline
                    M Offline
                    Mikeeeeee
                    wrote on last edited by
                    #9

                    Thanks! I didn't specify the name of the objects.

                    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