Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Italian
  4. QDockWidget salvare e ripristinare la posizione
Forum Updated to NodeBB v4.3 + New Features

QDockWidget salvare e ripristinare la posizione

Scheduled Pinned Locked Moved Unsolved Italian
3 Posts 2 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.
  • T Offline
    T Offline
    theking0
    wrote on last edited by
    #1

    Salve, sto trovando problemi col il salvataggio della posizione dei dockwigets.
    Sembra che salvi correttamente vedendo il file ini, e anche nel caricamento sembra non avere problemi visto che la "restoreGeometry" ritorna true ... eppure i widget non vengono ripristinati, ma appaiono sempre nella posizione che hanno anche nel designer di qtcreator.

    Il codice che uso per il salvataggio è il seguente:

        QList<QDockWidget*> docks = this->findChildren<QDockWidget*>();
        foreach (QDockWidget *widget, docks) {
            set.setValue(widget->objectName(), widget->saveGeometry());
        }
    

    questo è quello per il load dei setting:

        QList<QDockWidget*> docks = this->findChildren<QDockWidget*>();
        foreach (QDockWidget *widget, docks) {
            bool ret = widget->restoreGeometry(
                        set.value(widget->objectName()).toByteArray());
            if(!ret) qWarning()<< "Dock widgets, load settings. Error";
        }
    

    avete qualche idea a riguardo ?

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      Noto che lo stai facendo manualmente, hai pensato a usare QMainWindow::saveState direttamente?

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      0
      • T Offline
        T Offline
        theking0
        wrote on last edited by
        #3

        Ops .. scusate il fail. Convinto che dovevo salvarmeli manualmente non avevo letto bene (o per niente) la documentazione che effettivamente è molto chiara:

        ...
        QByteArray QMainWindow::saveState(int version = 0) const
        ...
        Saves the current state of this mainwindow's toolbars and dockwidgets. This includes the corner settings which can be set with setCorner(). The version number is stored as part of the data.
        ...

        Grazie VRonin per avermi auitato.

        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