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. restoreState() any way to remove layout data for named QWidgets?
Forum Update on Monday, May 27th 2025

restoreState() any way to remove layout data for named QWidgets?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 506 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.
  • C Offline
    C Offline
    caleb
    wrote on last edited by caleb
    #1

    I am working on a project using QT 5.6 that makes use of various windows and dockwidgets and some of these widgets/windows can be opened via Lua script calls in our engine. When they are opened, the window layout is restored again to apply the layout data to any dockwidgets that may not have been opened at load time.

    The normal behavior of restoreState is great but we have an edge case with this where if a user has changed the layout of their dockwidgets and then opens a new dockwidget their layout is reset to the previously saved version rather than taking their changes into account.

    I would saveState() again but this would lose information about windows which are not yet open and have had a layout saved from previous sessions. What we need is a way to flag certain named dockwidgets as having been manually resized and to avoid setting the layout on those manually resized widgets when we call restoreState() again.
    Is there a way I can make this happen?

    Thank you in advance!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Frome the looks of it you would need to either do a "pre-parsing" of the state and remove everything you don't want from it. Or re-implement restoreState to do what you want. Note that this is not virtual function so you will have your own version mimicking the original behaviour to some extent.

      Hope it helps.

      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

      • Login

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