Display of QComboBox in QTableView
-
Good afternoon,
I have maybe not so large but complex set of data to be displayed in QTableView. In general it is custom user database stored in in-memory sqlite. Nothing out of ordinary. This display is read only. Data is supplied by standard QSqlTableModel, data is static as refreshing the model requires fresh poll from external source.
However in a few columns data is a set of mail addresses - in order no to clutter or stretch columns too wide I'd like to display them as combo box in the cell - so user that needs to check can just expand the box to see the emails. I wrote a relevant delegate and it works... but only if I trigger edit event on the cell (double click or whatever is set). I might misinterpret docs but it is written:
The items shown in a table view, like those in the other item views, are rendered and edited using standard delegates.
For performance reasons I'd like to avoid inserting combo boxes as widgets - with 500 users, four columns with such data...
Is there something else I can do? Or am I wrong and inserting so many widgets will have minimum impact on performance?Stack: Qt6, qmake, macOS/Windows/Linux.
Many thanks for any insight.
-
Hi,
If memory serves well, you might be able do to what you want using QStyledItemDelegate::editorEvent.
Hope it helps