setColumnHidden() not working for cell widget ?
-
Hi all,
I have a QTableWidget populated with many rows and colums... some columns are made of standard QTableWidgetItem(), others are populated using setCellWidget()...
Everything works as expected until I try to dynamically show/hide some colums using setColumnHidden()... which seems to work only for standard columns but not for colums that contains widgets (comboBoxex in my case)... is this an expected behaviour ?
thanks a lot, Giampaolo
-
Hi all,
I have a QTableWidget populated with many rows and colums... some columns are made of standard QTableWidgetItem(), others are populated using setCellWidget()...
Everything works as expected until I try to dynamically show/hide some colums using setColumnHidden()... which seems to work only for standard columns but not for colums that contains widgets (comboBoxex in my case)... is this an expected behaviour ?
thanks a lot, Giampaolo
-
Hi all,
I have a QTableWidget populated with many rows and colums... some columns are made of standard QTableWidgetItem(), others are populated using setCellWidget()...
Everything works as expected until I try to dynamically show/hide some colums using setColumnHidden()... which seems to work only for standard columns but not for colums that contains widgets (comboBoxex in my case)... is this an expected behaviour ?
thanks a lot, Giampaolo
-
Hi,
I am not quite surprised as setCellWidget should be used only to show some static content. If you need better integration, you should implement a custom QStyledItemDelegate.
-
73 Giampaolo,
As a fallback, you could enable/disable the UI controls (combo boxes). They would still be visible but blocked from end user usage.
I have always found the QTableWidget and QListWidget helpful for simple textual displays, but anything more complicated and I switch to QTableView and manage the model separately. This also makes the QDataWidgetMapper available which is a fun toy. I use that with message content display when the user clicks on a table row (like an email client might use).
Mitch
ab4mw -
Hi all and thanks for the support...
I confirm that setColumnHidden() does not work for cells containing widgets... below is an extract of my table:
what I'm trying to achieve is to hide some columns according to the user level (admin, supervisor, operator etc) to simplify the table for non-expert users... I'm already disabling some cells according to the selected type/contents but in this case I would like to hide completely some columns like type, order & size...
I know I can switch to QTableView but in this case, as the expected number of rows is low, I prefer to stay on a QTableWidget if possible...
BTW: I'm using Windows11 with QT6.4.2
I'll investigate it deeply today...
thanks again and Best Regards Giampaolo
-
Hi all,
while preparing a minimal piece of code to reproduce the behaviour, I found that setColumnHidden() seems to work even on columns made of widgets... I'll be back as soon as I got more info... sorry for the false-report.
Giampaolo
@iw2lsi said in setColumnHidden() not working for cell widget ?:
while preparing a minimal piece of code to reproduce the behaviour, I found that setColumnHidden() seems to work even on columns made of widgets...
Which is what I suggested :) Which is why one should always prepare a minimal example illustrating a problem...!
-
@iw2lsi said in setColumnHidden() not working for cell widget ?:
while preparing a minimal piece of code to reproduce the behaviour, I found that setColumnHidden() seems to work even on columns made of widgets...
Which is what I suggested :) Which is why one should always prepare a minimal example illustrating a problem...!
-