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

[4.4.0] QDockWidget visibilityChanged(bool) / isVisible() bug

    XMLWordPrintable

Details

    Description

      Run the code below and click alternatively on Dock 1 and Dock2.
      The results of the visibilityChanged(bool) signal and isVisible() do not match.

      //--------------------------------------------
      #include <QtGui>

      class MainWindow : public QMainWindow
      {
      Q_OBJECT

      public:
      MainWindow() : QMainWindow()

      { QTextEdit * textEdit = new QTextEdit; textEdit->insertPlainText( "Hello World" ); setCentralWidget( textEdit ); dock1 = new QDockWidget( this ); dock1->setWidget( new QTextEdit( dock1 ) ); dock1->setWindowTitle( "Dock 1" ); addDockWidget( Qt::RightDockWidgetArea, dock1 ); dock2 = new QDockWidget( this ); dock2->setWidget( new QTextEdit( dock2 ) ); dock2->setWindowTitle( "Dock 2" ); tabifyDockWidget( dock1, dock2 ); QObject::connect( dock1, SIGNAL( visibilityChanged( bool ) ), this, SLOT( printDock1( bool ) ) ); QObject::connect( dock2, SIGNAL( visibilityChanged( bool ) ), this, SLOT( printDock2( bool ) ) ); }

      public slots:
      void printDock1( bool b )
      {
      if ( b )

      { if ( dock1->isVisible() ) qDebug( "dock1 is visible" ); else qDebug( "dock1 is visible, but isVisible() contradicts" ); }

      else

      { if ( ! dock1->isVisible() ) qDebug( "dock1 is invisible" ); else qDebug( "dock1 is invisible, but isVisible() contradicts" ); }

      qDebug();
      }

      void printDock2( bool b )
      {
      if ( b )

      { if ( dock1->isVisible() ) qDebug( "dock2 is visible" ); else qDebug( "dock2 is visible, but isVisible() contradicts" ); }

      else

      { if ( ! dock1->isVisible() ) qDebug( "dock2 is invisible" ); else qDebug( "dock2 is invisible, but isVisible() contradicts" ); }

      qDebug();
      }

      private:
      QDockWidget * dock1;
      QDockWidget * dock2;
      };

      int main( int argc, char * argv[] )
      {
      QApplication app( argc, argv );
      MainWindow mainWindow;
      mainWindow.show();
      return app.exec();
      }

      #include "main.moc"
      //--------------------------------------------

      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)
            admin Administrator
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes