How to get selected item of QTableWidget with QLabel in it
Unsolved
General and Desktop
-
In my QTableWidget, I fill some cells with QLabel by:
ui->myTableWidget->setCellWidget(1, 1, new QLabel("test"));
When I click the cells they will show as selected, but I can't seem to get the selection on them by doing:
ui->myTableWidget->selectedItems()
This will return nothing even a few cells with QLabel in it are actually selected. Is there any way to go around this using QTableWidget? Thanks.
-
Hi,
Why are you putting a QLabel in QTableWidget cell to show text since QTableWidget already shows text ?
-
@Pauly You can mark an table item read-only using https://doc.qt.io/qt-5/qt.html#ItemFlag-enum and setFlags()
For fonts there is https://doc.qt.io/qt-5/qtablewidgetitem.html#setFont