Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Unexpected console messages for selection changes in QTreeView

Unexpected console messages for selection changes in QTreeView

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 397 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rprueckl
    wrote on last edited by
    #1

    I have a QTreeView embedded in a layout structure that resides in a QMainWindow (because I use a QToolBar), which is embedded in a QDockWidget that is docked at the left side of my top-level QMainWindow.
    The QTreeView is coming from the Designer.
    For demonstration, I initialize it with a QStandardItemModel as follows:

    QStandardItemModel *model = new QStandardItemModel();
    
    QStandardItem *parentItem = model->invisibleRootItem();
    
    parentItem->appendRow(new QStandardItem("row1"));
    parentItem->appendRow(new QStandardItem("row2"));
    parentItem->appendRow(new QStandardItem("row3"));
    
    parentItem->child(0)->appendRow(new QStandardItem("subrow11"));
    parentItem->child(1)->appendRow(new QStandardItem("subrow21"));
    parentItem->child(2)->appendRow(new QStandardItem("subrow31"));
    
    ui.cameraTreeView->setModel(model);
    

    Now, when I expand (some of) the top-level rows and change the selected entry, on the console output like the following is generated (several lines per selection change):

    qt.accessibility.core: Cannot create accessible child interface for object:  QTreeView(0x1c7b87e5a90, name = "cameraTreeView")  index:  5
    qt.accessibility.core: Cannot create accessible child interface for object:  QTreeView(0x1c7b87e5a90, name = "cameraTreeView")  index:  5
    qt.accessibility.core: Cannot create accessible child interface for object:  QTreeView(0x1c7b87e5a90, name = "cameraTreeView")  index:  5
    qt.accessibility.core: Cannot create accessible child interface for object:  QTreeView(0x1c7b87e5a90, name = "cameraTreeView")  index:  5
    qt.accessibility.core: Cannot create accessible child interface for object:  QTreeView(0x1c7b87e5a90, name = "cameraTreeView")  index:  5
    qt.accessibility.core: Cannot create accessible child interface for object:  QTreeView(0x1c7b87e5a90, name = "cameraTreeView")  index:  6
    qt.accessibility.core: Cannot create accessible child interface for object:  QTreeView(0x1c7b87e5a90, name = "cameraTreeView")  index:  6
    qt.accessibility.core: Cannot create accessible child interface for object:  QTreeView(0x1c7b87e5a90, name = "cameraTreeView")  index:  6
    qt.accessibility.core: Cannot create accessible child interface for object:  QTreeView(0x1c7b87e5a90, name = "cameraTreeView")  index:  6
    qt.accessibility.core: Cannot create accessible child interface for object:  QTreeView(0x1c7b87e5a90, name = "cameraTreeView")  index:  6
    qt.accessibility.core: Cannot create accessible child interface for object:  QTreeView(0x1c7b87e5a90, name = "cameraTreeView")  index:  5
    qt.accessibility.core: Cannot create accessible child interface for object:  QTreeView(0x1c7b87e5a90, name = "cameraTreeView")  index:  5
    

    Does someone have an idea what the problem here could be?
    I am working on Windows 10, I have seen the behavior using Qt 5.10.0 and 5.12.2 (debug binaries). Thanks.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      It really sounds like this one
      https://bugreports.qt.io/browse/QTBUG-33247
      but should be fixed many versions ago.

      So that code + ui form with QTreeView is enough to trigger the message ?

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rprueckl
        wrote on last edited by
        #3

        Thanks for the hint. I am aware of this bug entry, but I thought the same: the issue should have been resolved already some versions ago.
        I will prepare a minimal example tomorrow morning and report about the outcome here.

        1 Reply Last reply
        1
        • R Offline
          R Offline
          rprueckl
          wrote on last edited by
          #4

          I made a minimal example of this and know now how to replicate the behavior. The example is as follows:

          QTreeViewTest.ui:

          <?xml version="1.0" encoding="UTF-8"?>
          <ui version="4.0">
           <class>QTreeViewTestClass</class>
           <widget class="QMainWindow" name="QTreeViewTestClass">
            <property name="geometry">
             <rect>
              <x>0</x>
              <y>0</y>
              <width>885</width>
              <height>645</height>
             </rect>
            </property>
            <property name="windowTitle">
             <string>QTreeViewTest</string>
            </property>
            <widget class="QWidget" name="centralWidget">
             <layout class="QVBoxLayout" name="verticalLayout">
              <item>
               <widget class="QGroupBox" name="groupBox">
                <property name="enabled">
                 <bool>false</bool>
                </property>
                <property name="title">
                 <string>GroupBox</string>
                </property>
                <layout class="QVBoxLayout" name="verticalLayout_2">
                 <item>
                  <widget class="QTreeView" name="treeView">
                   <attribute name="headerVisible">
                    <bool>false</bool>
                   </attribute>
                  </widget>
                 </item>
                </layout>
               </widget>
              </item>
             </layout>
            </widget>
           </widget>
           <layoutdefault spacing="6" margin="11"/>
           <resources>
            <include location="QTreeViewTest.qrc"/>
           </resources>
           <connections/>
          </ui>
          

          QTreeViewTest.h:

          #pragma once
          
          #include <QtWidgets/QMainWindow>
          #include "ui_QTreeViewTest.h"
          
          class QTreeViewTest : public QMainWindow
          {
              Q_OBJECT
          
          public:
              QTreeViewTest(QWidget *parent = Q_NULLPTR);
          
          protected slots:
              void fillTreeView();
          
          private:
              Ui::QTreeViewTestClass ui;
          
          };
          

          QTreeViewTest.cpp:

          #include "QTreeViewTest.h"
          
          #include <QStandardItemModel>
          #include <QTimer>
          
          QTreeViewTest::QTreeViewTest(QWidget *parent)
              : QMainWindow(parent)
          {
              ui.setupUi(this);
          
              //ui.groupBox->setEnabled(false);
          
              QTimer::singleShot(1000, this, &QTreeViewTest::fillTreeView);
          }
          
          void QTreeViewTest::fillTreeView()
          {
              //ui.groupBox->setEnabled(false);
          
              QStandardItemModel *model = new QStandardItemModel();
          
              QStandardItem *parentItem = model->invisibleRootItem();
          
              parentItem->appendRow(new QStandardItem("row1"));
              parentItem->appendRow(new QStandardItem("row2"));
              parentItem->appendRow(new QStandardItem("row3"));
          
              parentItem->child(0)->appendRow(new QStandardItem("subrow11"));
              parentItem->child(1)->appendRow(new QStandardItem("subrow21"));
              parentItem->child(2)->appendRow(new QStandardItem("subrow31"));
          
              ui.treeView->setModel(model);
          
              ui.groupBox->setEnabled(true);
          }
          

          The QTreeView is embedded in a QGroupBox. The appearance of the effect depends on the enabled state (i.e. void setEnabled(bool)) of the QGroupBox.

          The following cases list scenarios about appearance of the debug output in dependence of the enabled state of the QGroupBox:
          QGroupBox disabled in Designer: YES
          QGroupBox disabled in constructor of QTreeViewTest: NO
          QGroupBox disabled as first statement in fillTreeView(): NO

          For completeness, the following cases list scenarios about appearance of the debug output in dependence of the enabled state of the QTreeView itself:
          QTreeView disabled in Designer and enabled at the end of fillTreeView(): NO
          QTreeView disabled in constructor of QTreeViewTest and enabled as last statement in fillTreeView(): NO
          QTreeView disabled as first statement in fillTreeView() and enabled as last statement in fillTreeView(): NO

          The conclusion of my investigation therefore is that the effect only appears when the QTreeView resides in a QGroupBox that comes disabled from the designer. The effect also does not change if I enable the QGroupBox before I set the QStandardItemModel to the QTreeView.

          I now work around this issue by disabling my QGroupBox in the constructor of the parent object instead of disabling it the designer file. However, maybe someone can investigate further to identify the root-cause of this.

          1 Reply Last reply
          2
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi,

            Thanks for that thorough investigation !

            I think you have enough material here to create a bug report here.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            R 1 Reply Last reply
            1
            • SGaistS SGaist

              Hi,

              Thanks for that thorough investigation !

              I think you have enough material here to create a bug report here.

              R Offline
              R Offline
              rprueckl
              wrote on last edited by
              #6

              @SGaist

              Done here: https://bugreports.qt.io/browse/QTBUG-83327

              1 Reply Last reply
              3

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved