Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.6.2
-
None
Description
The below code will not resize correctly:
A Pull Request has been send to gerrit:
https://codereview.qt-project.org/c/qt/qtbase/+/549686
#include <QApplication> #include <QTableWidget> #include <QHeaderView> class Colorfull : public QWidget { public: Colorfull(const QSize& size, QWidget *parent= nullptr) : QWidget(parent) { setStyleSheet("background-color:red;"); setFixedSize(size); } }; int main(int argc, char **argv) { QApplication app (argc, argv); QTableWidget table; table.setGeometry(0,0,400,400); table.setColumnCount(2); table.setRowCount(2); table.setHorizontalHeaderLabels({"First", "Second"}); table.horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents); table.horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch); table.verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); // Not Working table.setCellWidget(0, 0, new Colorfull(QSize(200,100))); table.setCellWidget(1, 0, new Colorfull(QSize(100,100))); // Working (Largest Widget Last) // table.setCellWidget(0, 0, new Colorfull(QSize(100,100))); // table.setCellWidget(1, 0, new Colorfull(QSize(200,100))); table.setItem(0, 1, new QTableWidgetItem("Some text")); table.setItem(1, 1, new QTableWidgetItem("Some more text")); table.show(); return app.exec(); }
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-123534 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
549686,4 | Fixes table widget not resizing column width correctly. | dev | qt/qtbase | Status: NEW | -1 | 0 |