QTableWidget cellwidget set invisible become visible after column resize
-
I have a
QTableWidget
where I have cells that contain aQPushButton
and at some point I won't need those buttons anymore so instead of removing (removeCellWidget) I decided to just make them invisible. However, after I do it, if that cell size ever changes, during a window resize for example, the buttons recently setVisible(false) become visible again.MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); ui->table->setRowCount(1); QPushButton *p = new QPushButton("Test"); ui->table->setCellWidget(0, 0, p); connect(p, &QPushButton::clicked, [p]() { p->setVisible(false); }); }
With this minimum working example, after clicking the button it becomes invisible but if you resize the column or row it becomes visible again.
Is it meant to behave like this?
-
Hi,
Which version of Qt are you using ?
On which platform ? -
Can you check with Qt 5.15 ?
-
While it might seem surprising, I would say it's not unexpected. The goal of setWidget is to show static content so handling its visibility is likely not something that has been implemented.
-
One thing you can do is to check the bug report system. If there's nothing there, you can consider opening a new ticket providing a minimal compilable example.
-
Dupe of https://bugreports.qt.io/browse/QTBUG-13522 - don't use widgets in itemviews. We really should have deprecate this widget inside item views stuff in Qt6...