Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-10694

Setting an itemview branch background using stylesheets

    XMLWordPrintable

Details

    Description

      When setting a background color using stylesheet, the icons and branches will be painted over by a rectangle of this color rather than being painted on top of this background.

      Example
      #include <QtGui>
      
      class TreeWidget : public QTreeWidget
      {
          Q_OBJECT
      public:
          TreeWidget(QWidget *parent = 0) : QTreeWidget(parent)
          {
              QTreeWidgetItem *item = new QTreeWidgetItem(this, QStringList() << "Oak");
              new QTreeWidgetItem(item, QStringList() << "Birch");
              new QTreeWidgetItem(this, QStringList() << "Fir");
              new QTreeWidgetItem(this, QStringList() << "Pine");
          }
      };
      
      #include "main.moc"
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
          QWidget widget;
          TreeWidget box;
          box.setStyleSheet("QTreeWidget::branch:selected {background: green;}");
          QVBoxLayout layout(&widget);
          layout.addWidget(&box);
          widget.show();
          return app.exec();
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            mpejcoch Martin Pejcoch (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes