Results 1 to 4 of 4

Thread: I need help resizing QDockWidgets Mannually

  1. #1
    Join Date
    Jun 2008
    Posts
    83
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default I need help resizing QDockWidgets Mannually

    Hi:

    I have problems setting the geometry of QDockWidgets manually. Here is the two concerning functions:
    Qt Code:
    1. void MineEdit::SaveSettings(){
    2. ui->dwErrorList->setVisible(false);
    3. QSettings settings("settings",QSettings::IniFormat);
    4. settings.setValue("exists",1);
    5. settings.setValue("windowsizes/window",this->geometry());
    6. settings.setValue("windowsizes/logger",ui->dwLog->geometry());
    7. settings.setValue("windowsizes/editor",ui->dwEditor->geometry());
    8. qDebug() << "Setting editor geometry to" << ui->dwEditor->geometry();
    9. settings.setValue("windowsizes/rwords",ui->dwWords->geometry());
    10. settings.setValue("windowsizes/isRwordsVisible",ui->dwWords->isVisible());
    11. settings.setValue("documents/lastdoc",CurrentDoc);
    12. }
    13.  
    14. bool MineEdit::ReloadSettings(){
    15. QSettings settings("settings",QSettings::IniFormat);
    16. if (settings.value("exists").toInt() == 1){
    17. this->setGeometry(settings.value("windowsizes/window").toRect());
    18. ui->dwLog->setGeometry(settings.value("windowsizes/logger").toRect());
    19. ui->dwEditor->setGeometry(settings.value("windowsizes/editor").toRect());
    20. qDebug() << "Restoring editor geometry to" << settings.value("windowsizes/editor").toRect();
    21. ui->dwWords->setGeometry(settings.value("windowsizes/rwords").toRect());
    22. ui->dwWords->setVisible(settings.value("windowsizes/isRwordsVisible").toBool());
    23. CurrentDoc = settings.value("documents/lastdoc").toString();
    24. return true;
    25. }
    26. return false;
    27. }
    To copy to clipboard, switch view to plain text mode 
    The function save settings is called when the program closes. While Reload is called in the main class's constructor.
    The problem is that the code correctly saves the dimensions I save for the dockwidget and it also correctly loads them. However they are not applied.

    My lay out looks like the image that says editor_when_open. I modify it to look like it shows in editor_when_modified and when I close and open my app again it looks like editor_when_open again even though the qDebug says that it saves and restores the modifed geometry.

    What am I doing wrong?

    Thanks for any answers
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: I need help resizing QDockWidgets Mannually

    you have to call ReloadSettings() after the MainWindow is visible.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jun 2008
    Posts
    83
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: I need help resizing QDockWidgets Mannually

    Ok, that was my theory.

    However it does not work if I call it during resizeEvent either. So what event should I redefine?

    Thank you.

  4. #4
    Join Date
    Jun 2008
    Posts
    83
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: I need help resizing QDockWidgets Mannually

    Problem Solved!

    I used QMainWindow::[restore/save]State() and QMainWindow::[restore/save]Geometry() instead of setting each value manually. And I still called the RestoreSettings in the constructor.

    Thanks for all the help!

Similar Threads

  1. Replies: 1
    Last Post: 2nd May 2010, 08:50
  2. Selecting tabbed QDockwidgets
    By trskel in forum Qt Programming
    Replies: 3
    Last Post: 25th September 2007, 17:22
  3. QDockWidgets without central widget
    By JoeMerchant in forum Qt Programming
    Replies: 17
    Last Post: 8th August 2007, 14:52
  4. centralWidget and QDockWidgets in designer
    By momesana in forum Qt Tools
    Replies: 1
    Last Post: 18th December 2006, 11:56
  5. QDockWidget dockable with other QDockwidgets
    By fellobo in forum Qt Programming
    Replies: 1
    Last Post: 8th April 2006, 10:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.