Results 1 to 2 of 2

Thread: QMainWindow ignores dynamically created, floating QDockWidget

  1. #1
    Join Date
    Feb 2010
    Location
    Sydney, Australia
    Posts
    111
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QMainWindow ignores dynamically created, floating QDockWidget

    If I dynamically create a floating QDockWidget and then call QMainWindow::saveState, the dynamically created QDockWidget's details are not saved. However, if I dock the QDockWidget to the QMainWindow and then call QMainWindow::saveState, the QDockWidget's details are saved. The details are also saved if I float the QDockWidget again. Seems that actually docking the QDockWidget to the QMainWindow has some effect on the operation of QMainWindow::saveState.

    Has anyone come across this before?

    Here is a code snippet from qmainwindowlayout.cpp:

    Qt Code:
    1. void QMainWindowLayoutState::saveState(QDataStream &stream) const
    2. {
    3. #ifndef QT_NO_DOCKWIDGET
    4. dockAreaLayout.saveState(stream);
    5. #endif
    6. #ifndef QT_NO_TOOLBAR
    7. toolBarAreaLayout.saveState(stream);
    8. #endif
    9. }
    To copy to clipboard, switch view to plain text mode 

    This is called as part of QMainWindow::saveState. the dynamically created QDockWidget is considered as belonging to one of the four dock areas until it has actually been docked in one of them.
    Last edited by stefanadelbert; 2nd March 2010 at 00:56.

  2. #2
    Join Date
    Feb 2010
    Location
    Sydney, Australia
    Posts
    111
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QMainWindow ignores dynamically created, floating QDockWidget

    Solved!

    The problem was that I was calling QMainWindow::addDockWidget and specifying Qt::AllDockWidgetAreas, which is nonsense. I changed to calling QMainWindow::addDockWidget and passing Qt::LeftDockWidgetArea and then calling QDockWidget::setFloating(true). This means that the floating QDockWidget is at least associated with a dock widget area and is, as a consequence, considered when calling QMainWindow::saveState.

    Rock.

Similar Threads

  1. making qmainwindow dynamically resizable to fit to screen
    By Amit_3117 in forum Qt Programming
    Replies: 4
    Last Post: 16th October 2009, 12:59
  2. QDockWidget : No floating
    By prashant in forum Qt Programming
    Replies: 1
    Last Post: 5th October 2009, 18:42
  3. Replies: 5
    Last Post: 21st November 2007, 09:51
  4. Dynamically Loading a QMainWindow?
    By natron in forum Newbie
    Replies: 10
    Last Post: 21st July 2006, 01:15
  5. QMainWindow and its QDockWidget
    By Promethee in forum Qt Programming
    Replies: 2
    Last Post: 13th January 2006, 20:42

Tags for this Thread

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.