Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTreeWidget item border style breaks selection style

QTreeWidget item border style breaks selection style

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 740 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nikita Kobzev
    wrote on last edited by
    #1

    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:

    e6e593db-ca2f-4f5b-90aa-08a8d05e022d-image.png

    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.

    328e7d41-4135-4662-97d6-24b1eff14659-image.png

    What exactly goes wrong is:

    1. Outline color changes to Red.
    2. 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?

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      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();
      }
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      4

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved