-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.5.3, 6.9.1
-
None
When a specific style sheet is applied to the QTreeWidgetItem, the hover action behaves as the focus-in action for the item's internal widget.
Correct | Wrong |
---|---|
focusIssue-correct.mp4![]() |
focusIssue-wrong.mp4![]() |
Minimal example:
#include <QLineEdit> #include <QTreeWidget>MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { const auto rowCount = 10; const auto colCount = 5; auto treeWidget = new QTreeWidget; treeWidget->setColumnCount(colCount); setCentralWidget(treeWidget); for (auto r = 0; r < rowCount; ++r) { auto topItem = new QTreeWidgetItem; treeWidget->addTopLevelItem(topItem); topItem->setExpanded(true); for (auto c = 0; c < colCount; ++c) { treeWidget->setItemWidget(topItem, c, new QLineEdit); } } setStyleSheet(R"( QTreeWidget::item { border-width: 1px; border-style: dashed; } QTreeWidget::item:hover {} )"); }
Notes:
- The same is true for the QTreeView class, but this code is more consistent.
- When the QTreeWidget::item part is removed, the behavior is still wrong, just slightly different.
- When the hover part is removed, the behavior is correct.