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

QComboBox in QTableWidget clobbers adjacent columns in 5.11

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Out of scope
    • Icon: P1: Critical P1: Critical
    • None
    • 5.11.1
    • Widgets: Layout
    • None
    • Linux/X11, macOS, Windows

      Hi, before 5.11, regardless of how long an item/string is in a QComboBox inserted in a QTableWidget, it never overflows into other columns. I haven't tested on 5.11.0, but on 5.11.1 if the string is too long, it will happily render into other columns to the right. This is probably just me missing/not understanding the documentation, or?

      To reproduce, create an empty vanilla widgets app.

      In main.cpp, add these #include lines:

      #include "QPushButton"
      #include "QTableWidget"
      #include "QVBoxLayout"
      #include "QComboBox"
      

      Add this static var:

      static QStringList sl = {"Now","is","the","time","for","all","good","men"
                               "to","come","to","the","aid","of","the","party."};
      

      Remove these lines:

      MainWindow w;
      w.show();
      

      Instead, insert these lines:

      auto bu = new QPushButton("Add one row");
      
      auto tw = new QTableWidget(1,3);
      tw->setColumnWidth(0,100);
      tw->setColumnWidth(1,100);
      tw->setColumnWidth(2,100);
      
      auto vb = new QVBoxLayout;
      vb->addWidget(bu);
      vb->addWidget(tw);
      
      auto wi = new QWidget();
      wi->setGeometry(0,0,500,600);
      wi->setLayout(vb);
      wi->show();
      
      bu->connect(bu,&QPushButton::clicked,[tw]
      {
          int rows = tw->rowCount();
      
          QString s;
          for (int r = 0; (r < rows); ++r)
              s += sl[r % sl.count()] + " ";
      
          auto cb = new QComboBox();
          cb->addItem(s);
          tw->setCellWidget(rows - 1,0,cb);
      
          auto bu = new QPushButton("Button");
          tw->setCellWidget(rows - 1,1,bu);
      
          tw->setItem(rows - 1,2,new QTableWidgetItem("Static text"));
      
          tw->setRowCount(++rows);
      });
      

      If I try in 5.10.1 the QComboBox behaves nicely and do not clobber the other columns, but in 5.11.1 not so

      Perhaps there is a header setting I've overlooked?

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

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            hskoglund Henry Skoglund
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes