QDockWidget layout changes after minimizing mainwindow



  • I am writing a small image viewer and I currently have these two tools docked in qdockwidgets in the right dock area. The problem is that after I minimize the main window the layout of the two docked widgets in the right hand dock area changes (initially they are placed one beneath the other in the right hand column and then they become spaced).

    Here is the code that creates the widgets:

    @setDockOptions(!QMainWindow::AllowTabbedDocks);
    
    bczDockWidget = new QDockWidget(tr("Basic operations"), this);
    bczDockWidget->setAllowedAreas(Qt::RightDockWidgetArea);
    
    
    //create tools
    bczTool = new BCZWidget(bczDockWidget);
    bczDockWidget->setWidget(bczTool);
    connect(bczTool,SIGNAL(brightness(double)), this, SLOT(brightness(double)));
    connect(bczTool,SIGNAL(contrast(double)), this, SLOT(contrast(double)));
    connect(bczTool,SIGNAL(zoom(int)), this, SLOT(zoom(int)));
    
    bczTool->setEnabled(false);
    bczDockWidget->setFeatures(!QDockWidget::DockWidgetClosable | !QDockWidget::DockWidgetMovable | !QDockWidget::DockWidgetFloatable);
    
    addDockWidget(Qt::RightDockWidgetArea, bczDockWidget);
    
    
    poDockWidget = new QDockWidget(tr("Point operations"), this);
    poDockWidget->setAllowedAreas(Qt::RightDockWidgetArea);
    
    poTool1 = new POwidget();
    poTool1->setEnabled(false);
    poTool1->setFixedWidth(bczTool->width());
    poDockWidget->setWidget(poTool1);
    
    connect(poTool1, SIGNAL(log(double)), this, SLOT(log(double)));
    poDockWidget->setFeatures(!QDockWidget::DockWidgetClosable | !QDockWidget::DockWidgetMovable | !QDockWidget::DockWidgetFloatable);
    
    addDockWidget(Qt::RightDockWidgetArea, poDockWidget);
    

    @
    I am using Qt 4.8.5 under Windows 8.



  • You will have to describe (or show) what you mean by "they become spaced."



  • This is the good layout.
    !http://s4.postimage.org/pvyo1d9xp/good_layout.png(Good layout)!

    This is the bad layout.
    !http://s18.postimage.org/6h446x3ex/bad_layout.png(Bad layout)!



  • I found the solution. I had to set a QSizePolicy::Fixed for both two QDockWidgets in order to have the good layout.



  • I have strange issues too with QDockwidgets. After mutliple showing/hiding combinations their size changes. I'm wondering if it appears with Qt 4.8.3 or 4.8.4 since I did not notice this behavior before.



  • [quote author="Julien M" date="1361394104"]I have strange issues too with QDockwidgets. After mutliple showing/hiding combinations their size changes. I'm wondering if it appears with Qt 4.8.3 or 4.8.4 since I did not notice this behavior before.
    [/quote]

    Yes, I have the same problem!
    I have a mainwindow with a lot of dockwidgets (17).
    Of course some of are hidden and some of are shown.
    I used them like a perspective. I have several perspective, and every perspective contains some dockwidgets wich are shown there.

    But!

    When I change between the perspectives (means: show or hide the dockwidgets), I always have problem with the size of dockwidgets. They are always arbitrarily changing! This is so annoying.
    I cannot find solution for this problem.

    One more problem what I have:
    I use some dockwidgets as overlapped (tabifyDockWidget()).
    But we don't have "out-of-box" disTabifyDockWidget().
    And when dockwidgets are hidden and tabified I can't query the tabifiedDockWidgets! Always give me a wrong result (empty list).

    And:
    There are a saveState() and restoreState() methods. These save the dockwidgets position and state. But these are also buggy.
    I cannot restore the saved state of my dockwidgets...

    I use Qt 4.8.3, QtCreator 2.5.2, g++ 4.6.2, Win7



  • saveState() and restoreState() are not buggy in my opinion.
    But since you are (like me I guess) hiding/showing QDockWidgets at application start, the "bug" we both mentioned messes up the dockwidgets's sizes.

    I would like to build a simple project in order to demonstrate the issue but it's a bit random and I'm not always able to reproduce it. (sometime each time I hide then re-show a QDockwidget it is shrinking a bit more until it reaches its minimum size)

    broadpeak: did you had this issue with previous builds of Qt?



  • [quote author="Julien M" date="1361530797"]
    saveState() and restoreState() are not buggy in my opinion.
    But since you are (like me I guess) hiding/showing QDockWidgets at application start, the "bug" we both mentioned messes up the dockwidgets's sizes.

    I would like to build a simple project in order to demonstrate the issue but it's a bit random and I'm not always able to reproduce it. (sometime each time I hide then re-show a QDockwidget it is shrinking a bit more until it reaches its minimum size)

    broadpeak: did you had this issue with previous builds of Qt?
    [/quote]

    I don't know which is wrong: save or the restore method.
    I get a binary (ByteArray) file in save, and I cannot "humanread" that content. So I cannot decide, that in saving everything is good.

    "shrinking" problem: I see the same! When I show and hide more times one after the other, continuously shrinking its size to minimalsize.

    My project has started in summer last year. I used at that time the original Nokia Qt packet, in this packet the version of Qt was 4.7.4. The problem existed at that time TOO!
    But circa 2-3 month ago I changed the version to 4.8.3. But the problem still exist...



  • Do you have the problem with all your QDockWidget or just some of them?
    I'm wondering if it is linked to the fact that some contain spacers while others don't.



  • [quote author="Julien M" date="1361537649"]Do you have the problem with all your QDockWidget or just some of them?
    I'm wondering if it is linked to the fact that some contain spacers while others don't.[/quote]

    I have problem with all of them.



  • By chance, did you tried compiling with Qt5?



  • [quote author="Julien M" date="1361816400"]By chance, did you tried compiling with Qt5?[/quote]

    No, I haven't tried it. I use only Qt 4.8.3
    In our firm we (all) use the same verison of Qt, because of compatibility issues. And currently we are waiting for a "stable" Qt5.



  • @broadpeak: Looks like I only have issues with QDockWidgets that contain a QListView/QListWidget or QTableView/QTableWidget. Is it your case too?

    Within designer, if you preview your GUI (Ctrl+R) and undock a QDockWidget with a QListView, then its size is altered and that could explain why it is not redocking properly.



  • [quote author="Julien M" date="1363690038"]@broadpeak: Looks like I only have issues with QDockWidgets that contain a QListView/QListWidget or QTableView/QTableWidget. Is it your case too?

    Within designer, if you preview your GUI (Ctrl+R) and undock a QDockWidget with a QListView, then its size is altered and that could explain why it is not redocking properly.[/quote]

    In my dockwidgets: there are 10 tableview, 5 listview, 1 treeview and 1 graphicsview.
    I use no designer for this project, I build all of the widgets "by hand" (*.h, *.cpp).


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.