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

QTreeWidgetItem not selected when right-clicking on the item to open a context menu

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P2: Important P2: Important
    • 4.6.0
    • 4.4.0
    • Widgets: Itemviews
    • None

      Tree item is not selected when right-clicking on the item to open a context menu.

      Steps to reproduce:

      Running the example code, Right-click on the item "root1" to open a context menu.
      Do not select anything from the above context menu and then right-click on the item "root2".
      "root2" is not selected.

      Example code:

      #include <QtGui>

      int main(int argc, char** argv)
      {
      QApplication app(argc, argv);

      QTreeWidget* tree = new QTreeWidget();

      QStringList roots1;
      roots1 << "root1";
      QStringList roots2;
      roots2 << "root2";
      QTreeWidgetItem* root1 = new QTreeWidgetItem(roots1);
      QTreeWidgetItem* root2 = new QTreeWidgetItem(roots2);
      QStringList children1;
      children1 << "child1";
      QStringList children2;
      children2 << "child2";
      QTreeWidgetItem* child1 = new QTreeWidgetItem(root1, children1);
      QTreeWidgetItem* child2 = new QTreeWidgetItem(root2, children2);
      tree->addTopLevelItem(root1);
      tree->addTopLevelItem(root2);

      QAction* openAction = new QAction("&Open", tree);
      QAction* closeAction = new QAction("&Close", tree);
      tree->addAction(openAction);
      tree->addAction(closeAction);
      tree->setContextMenuPolicy(Qt::ActionsContextMenu);

      tree->show();

      return app.exec();
      }

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

            monsen Marius Bugge Monsen
            xcm Martin Petersson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes