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. [Solved] MainWindow example not restore layout of qdockwidgets which are added later
Forum Updated to NodeBB v4.3 + New Features

[Solved] MainWindow example not restore layout of qdockwidgets which are added later

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.8k Views 1 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.
  • D Offline
    D Offline
    dasun
    wrote on last edited by
    #1

    I'm trying to create a widget based app similar to MainWindow (QDockWidget) example. Take the example it self as an examle. It don't restore layout for QDockWidget which are added latter(QDockWidget wich are added after QMainWindow::show() method calls). What is the reason for that? Is that because widgets are added after QMainWinows is shown? or something else? How can I overcome this?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      Do you mean that it does not restore layout after application restart?
      If so then you need to use "QSettings":http://qt-project.org/doc/qt-5/qsettings.html to save and restore a layout.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dasun
        wrote on last edited by
        #3

        No, I'm talking about the example project comes with Qt. In that application you can add custom widgets at run-time and save it layout to a file, When I open that layout file it wont restore qdockwidgets which are added later.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dasun
          wrote on last edited by
          #4

          Sorry for the trouble. I think I have changed ObjectName. Now it's working.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andreyc
            wrote on last edited by
            #5

            I guess you are talking about examples/widgets/mainwindows/mainwindow.

            It does restore the created and saved QDockWidget.
            But not immediately after you load layout.
            After you have loaded a layout you need to select "Add dock widget..." from "Dock Widgets" menu.
            Type the same name as you gave when you created that DockWidget and select "Restore" from "Location" drop-down bar.
            Click "Ok" and you will see it. :-)

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andreyc
              wrote on last edited by
              #6

              Yes. The ObjectName is important.
              Glad that you resolved it.

              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