QTreeWidget item border style breaks selection style
Unsolved
General and Desktop
-
Hi there. I'm trying to customize a
QTreeWidget::item
(QT v.6.0.0 msvc2019_64) and set a look for a border.Here is the unstyled component without/with selected items. It looks good:
But once I put the style to the widget:
QTreeWidget::item { border-bottom: 1px dotted grey; }
Something strange happens. The unselected view of the widget looks as expected, but when I select items, the view gets broken.
What exactly goes wrong is:
- Outline color changes to
Red
. - Background of items loses its default
Blue
highlight.
Can anyone point me out, cow could a border style cause that? Did I do something wrong, or that is a QT bug?
- Outline color changes to
-
Bug confirmed (On windows) for Qt 6.0.
Please try installing Qt 6.1.1 and see if it's already fixed.
If it's not, open a bug report, you can attach the below as a minimal example:#include <QApplication> #include <QTreeWidget> #include <QDialog> #include <QDialogButtonBox> #include <QVBoxLayout> int main(int argc, char *argv[]) { QApplication app(argc,argv); QDialog dial; dial.setWindowTitle(QStringLiteral("Edit Headers")); QDialogButtonBox *dialButtons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, &dial); QObject::connect(dialButtons, &QDialogButtonBox::accepted, &dial, &QDialog::accept); QObject::connect(dialButtons, &QDialogButtonBox::rejected, &dial, &QDialog::reject); QTreeWidget* treeWidget = new QTreeWidget(&dial); treeWidget->setColumnCount(2); treeWidget->model()->insertRows(0,2); treeWidget->model()->setHeaderData(0,Qt::Horizontal,QStringLiteral("Name")); treeWidget->model()->setHeaderData(1,Qt::Horizontal,QStringLiteral("Value")); treeWidget->model()->setData(treeWidget->model()->index(0,0),QStringLiteral("h1")); treeWidget->model()->setData(treeWidget->model()->index(0,1),QStringLiteral("v1")); treeWidget->model()->setData(treeWidget->model()->index(1,0),QStringLiteral("h2")); treeWidget->model()->setData(treeWidget->model()->index(1,1),QStringLiteral("v2")); QVBoxLayout* dialLay = new QVBoxLayout(&dial); dialLay->addWidget(treeWidget); dialLay->addWidget(dialButtons); dial.setStyleSheet(QStringLiteral("QTreeWidget::item { border-bottom: 1px dotted grey; }")); dial.show(); return app.exec(); }