Congratulations to our 2022 Qt Champions!

CellClicked signal does not work when showing rich text in the cell

  • I have a QTableWidget, one column of the table are rich text. cellClicked(int,int) signal does not work for rich text column.

    For example, I assigned following rich text value to a cell:

    dataViewTable->setCellWidget(0, 0, new QLabel("<font color=red>TEST</font>"));

    cellClicked(int,int) signal does not work when I click this cell. The click signal works for other cells. How to fix this problem?

  • Moderators

    When you use a cell widget it's that widget that gets the clicks, not the table widget.

    If you don't need to interact with the label you can make it "transparent" to mouse clicks:
    QLabel* label = new QLabel("<font color=red>TEST</font>");
    dataViewTable->setCellWidget(0, 0, label);

  • Great! It works for me. Thanks a lot!

Log in to reply