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

QAbstractItemView::indicator not working properly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 6.5.5-1, 6.6.3, 6.8.0 FF
    • 6.3.2, 6.4.0, 6.5.2, 6.6.2
    • Widgets: Itemviews
    • None
    • Windows10 + Qt
    • Windows
    • 1ac58f4ba (dev), da59bc343 (6.7), 347b35a44 (6.6), 3bc823495 (tqtc/lts-6.5)

    Description

      Hello!
      When I create a view/model and display the view's CheckBox, I only need to set the Qss about QAbstractItemView::indicator, such as QAbstractItemView::indicator { width: 6px; height: 6px; border: 1px solid black;}
      Then the display of the View is messed up at this time, and it looks like the original CheckBox and Styled CheckBox are drawn together.
      But this demo runs normally on Qt5.15.2. You can use the following simple Demo to reproduce:

      #include <QtWidgets>
      
      class TestModel : public QAbstractListModel
      {
          Q_OBJECT
      public:
          explicit TestModel(const QList<QString>& vals, QObject *parent = nullptr) : QAbstractListModel(parent), vals_{vals}{}
      
          int rowCount(const QModelIndex &parent = QModelIndex()) const {
              Q_UNUSED(parent)
              return vals_.size();
          }
          QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const {
              if (!index.isValid())
                  return QVariant();
      
              switch(role) {
              case Qt::DisplayRole:
                  return vals_.at(index.row());
              case Qt::CheckStateRole:
                  return Qt::Unchecked;
              default:
                  break;
              }
              return QVariant();
          }
      
      private:
          QList<QString> vals_;
      };
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          QListView view;
          view.setWindowTitle(qVersion());
          view.setModel(new TestModel(QList<QString>{QStringLiteral("11111"), QStringLiteral("22222"), QStringLiteral("33333")}, &view));
          view.setStyleSheet(QStringLiteral("QAbstractItemView::indicator { width: 6px; height: 6px; border: 1px solid black;}"));
          view.show();
      
          return a.exec();
      }
      
      #include "main.moc"
      

      Thanks

      Attachments

        1. 5.15.2.png
          5.15.2.png
          4 kB
        2. 6.3.2.png
          6.3.2.png
          4 kB
        3. 6.4.0.png
          6.4.0.png
          4 kB
        4. 6.5.2.png
          6.5.2.png
          4 kB
        5. 6.6.2.png
          6.6.2.png
          4 kB

        Issue Links

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

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              pupu5642 yaxin zhao
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes