Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
6.4.1
-
None
Description
When using QTreeView::indexAt with a position from mouse pointer, I get wrong results if the Header of the TreeView is visible:
The indexAt(QPos(10, 10)) result for each of these QTreeViews should be different (at least in my opinion...).
But both result in a valid QModelIndex:
QModelIndex(0,0,0x0,QStringListModel(0x21a34deb600)) QModelIndex(0,0,0x0,QStringListModel(0x21a34deb600))
As a minimal example to reproduce this behaviour, this can be taken:
#include "QTreeViewTest.h" #include <QVBoxLayout> #include <QTreeView> #include <QStringListModel> QTreeViewTest::QTreeViewTest(QWidget *parent) : QMainWindow(parent) { QStringListModel* model = new QStringListModel({ "One", "Two", "Three" }, this); resize(600, 400); QWidget* centralWidget = new QWidget(this); QVBoxLayout * verticalLayout = new QVBoxLayout(centralWidget); QTreeView* treeView1 = new QTreeView(centralWidget); treeView1->setObjectName("treeView1"); verticalLayout->addWidget(treeView1); treeView1->setModel(model); QTreeView* treeView2 = new QTreeView(centralWidget); treeView2->setObjectName("treeView2"); verticalLayout->addWidget(treeView2); treeView2->setModel(model); treeView2->setHeaderHidden(true); setCentralWidget(centralWidget); qDebug() << treeView1->indexAt(QPoint(10, 10)); qDebug() << treeView2->indexAt(QPoint(10, 10)); }