Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-9758

QDockWidget: If setFloating is called before show() on a tabified dock widget, the widget never shows and toggleViewActions stop working

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.7.0
    • 4.7.1
    • Widgets: Main Window
    • None
    • Mac OSX, Qt4, QDockWidget
    • de73874e1f52ed323b87a36d072048023d22112e

    Description

      Sample code with comments on the observed odd behavior is below:

      Bar.c++
      #include <QApplication>
      #include <QMainWindow>
      #include <QAction>
      #include <QDockWidget>
      #include <QMenu>
      #include <QSize>
      #include <QMenuBar>
      
      using namespace std;
      
      int main (int argc, char* argv[])
      {
        QApplication app(argc, argv);
        QMainWindow window;
        QDockWidget dock1(&window);
        QDockWidget dock2(&window);
        QMenu menu("View");
        
        dock1.setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
        dock2.setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
        
        dock1.setWindowTitle("Dock One");
        dock2.setWindowTitle("Dock Two");
        
        window.addDockWidget(Qt::RightDockWidgetArea, &dock1);
        window.addDockWidget(Qt::RightDockWidgetArea, &dock2);
        window.menuBar()->addMenu(&menu);
        window.setMinimumSize(QSize(800, 600));
      
        window.tabifyDockWidget(&dock1, &dock2);
        
        dock1.hide();
        dock2.hide();
        
        menu.addAction(dock1.toggleViewAction());
        menu.addAction(dock2.toggleViewAction());
        
        
      
        window.show();
        
        // Below is where the oddness starts. It seems to only exhibit the 
        // behavior if the dock widgets are tabified.
        
        
        // Odd behavior here
        // This does not work. the window never shows, though its menu action shows
        // checked. Not only does this window not show up, but all toggle actions
        // for all dock windows (e.g. dock1 and dock2) are broken for the duration
        // of the application loop.
        // dock1.setFloating(true);
        // dock1.show();
        
        
        // This does work. . . of course only if you do _not_ run the above first.
        // however, you can often get a little lag or "blip" in the rendering as
        // the dock is shown docked before setFloating is set to true.
        dock1.show();
        dock1.setFloating(true);
        return app.exec();
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vfm Thierry Bastian (closed Nokia identity) (Inactive)
            jkyle James A Kyle
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes