-
Bug
-
Resolution: Cannot Reproduce
-
P2: Important
-
4.4.0
-
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();
}