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

CLONE - QGraphicsTextItem in a tab of QTabWidget cannot get focus

    XMLWordPrintable

Details

    Description

      Any QGraphicsTextItems in those tabs which are not the first tab of QTabWidget, cannot get focus although the tab is current tab of QTabWidget.

      But the QGraphicsTextItem in the first tab of QTabWidget can get focus. i.e. a focus frame (dotted box) appears around the QGraphicsTextItem.

      Those QGraphicsTextItems which cannot get focus can get focus only after the main window is minimized and then maximized. i.e. After that, a focus frame appears around it.

      The minimal source code is below and attached:

      #include <QtGui/QApplication>
      #include <QTabWidget>
      #include <QGraphicsView>
      #include <QGraphicsScene>
      #include <QGraphicsTextItem>

      int main(int argc, char *argv[])
      {
      QApplication a(argc, argv);

      QTabWidget * t = new QTabWidget();
      QGraphicsView * v1 = new QGraphicsView(t);
      QGraphicsView * v2 = new QGraphicsView(t);
      QGraphicsScene * s1 = new QGraphicsScene(v1);
      QGraphicsScene * s2 = new QGraphicsScene(v2);
      QGraphicsTextItem * i1;
      QGraphicsTextItem * i2;

      t->show();

      v1->setScene(s1);
      v2->setScene(s2);

      t->addTab(v1, "view1");
      t->setCurrentWidget(v1);

      i1 = s1->addText("Text1");
      i1->setFlags(QGraphicsItem::ItemIsFocusable);
      i1->setTextInteractionFlags(Qt::TextEditorInteraction);
      i1->setEnabled(true);
      i1->setFocus();

      t->addTab(v2, "view2");
      t->setCurrentWidget(v2);

      i2 = s2->addText("Text2");
      i2->setFlags(QGraphicsItem::ItemIsFocusable);
      i2->setTextInteractionFlags(Qt::TextEditorInteraction);
      i2->setEnabled(true);
      i2->setFocus();

      return a.exec();
      }

      This problem happens also in Qt 4.7.0.

      Attachments

        1. main.cpp
          2 kB
          karsten
        2. patch.diff
          0.6 kB
          karsten
        3. screenshot-1.jpg
          9 kB
          karsten
        4. test.pro
          0.3 kB
          karsten
        5. test.pro.user
          8 kB
          karsten
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kavi Kalle Viironen
            karstenj karsten
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes