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

Left margin for QTableView::Item is set after resize only

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.12.3, 5.12.4, 5.12.5, 5.13.0
    • Widgets: Style Sheets
    • None
    • Windows

    Description

      In my application I postponed index widgets creation for QTableView. In the next example left margin (from stylesheet) will be applied after resize the view or after reset qss after insertion index widgets by: 

          v->style()->unpolish(v);
          v->style()->polish(v);
      

       

      Example:

      #include <QApplication>
      
      #include <QTableView>
      #include <QLabel>
      #include <QStringListModel>
      #include <QStringList>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          QTableView* v = new QTableView();
      
          v->setStyleSheet("QTableView::item\
          {\
              border: none;\
              padding: 0px;\
              margin: 0px 30px;\
          }");
      
          v->show();
      
          QStringListModel* m= new QStringListModel();;
          QStringList list;
          for (int i=0; i<10; ++i) list.append("");
      
          m->setStringList(list);
          v->setModel(m);
      
          a.processEvents(); 
      

      */mandatory too call two times at least/*

          a.processEvents(); 
      
          for (int i=0; i<m->rowCount(); ++i){
              v->setIndexWidget(m->index(i,0), new QLabel("uuid", v));
          }
      
          return a.exec();
      }
      

      before resize:
       

      after resize:

      Attachments

        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
            slava_yartsev Viacheslav Yartsev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes