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

QGraphicsScene::isActive() doesn't work correctly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P2: Important
    • 4.8.x
    • 4.6.2
    • Widgets: GraphicsView
    • None

    Description

      If you add tabs after the show event QGraphicsScene::isActive() is wrong.

      If you call bugReport.addTabs() before bugReport.show() it works as expected.

      main.h
      #include <QtGui>
      
      class BugReport : public QWidget
      {
          Q_OBJECT
      
      public:
          BugReport(QWidget *parent);
          void addTabs();
      
      private:
          QTabWidget *m_pTabWidget;
          QGraphicsScene *m_pGraphicsScene;
      
      private slots:
          void checkActive();
      };
      
      main.cpp
      #include "main.h"
      
      BugReport::BugReport(QWidget *parent) : QWidget(parent)
      {
          QBoxLayout *pLayout = new QVBoxLayout;
      
          QPushButton *pButton = new QPushButton(tr("Check Active!"));
          connect(pButton, SIGNAL(clicked(bool)), SLOT(checkActive()));
          pLayout->addWidget(pButton);
      
          m_pTabWidget = new QTabWidget;
          pLayout->addWidget(m_pTabWidget);
      
          m_pGraphicsScene = new QGraphicsScene();
      
          setLayout(pLayout);
      }
      
      void BugReport::addTabs()
      {
          m_pTabWidget->addTab(new QWidget(), "dummy");
          m_pTabWidget->addTab(new QGraphicsView(m_pGraphicsScene), "view");
      }
      
      void BugReport::checkActive()
      {
          QMessageBox::information(this, tr("QGraphicsScene::isActive()"), tr("QGraphicsScene::isActive() = %1").arg(m_pGraphicsScene->isActive()));
      }
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
          BugReport bugReport(0);
          bugReport.show();
          bugReport.addTabs();
          return app.exec();
      }
      

      Attachments

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

        Activity

          People

            lscunha Leonardo Sobral Cunha (Inactive)
            paroga Patrick R. Gansterer
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes