[Interest] Custom indicator on QTableWidgetItem

Murphy, Sean smurphy at walbro.com
Mon Nov 20 16:29:01 CET 2017


Some spreadsheet applications (notably MS Excel, Google Sheets, etc.) have a mechanism for indicating that a cell has a comment attached to it (see attached screenshot, the red triangle in the upper corner of the cell A1). Is there a way to do something similar with a QTableWidgetItem?

The only method I'm seeing at the moment is to create my own custom widget, like something that inherits from QLabel for example, that has this indicator, and then use QTableWidget::setCellWidget() to insert it where I want in the table. Am I missing some other method?

Other (possibly) important notes:
- the table is read-only, so I don't need to worry about making the QTableWidgetItem editable, so that's why my approach above suggest QLabel, not QLineEdit
- If there is a way to do it without a custom widget, I'd like to be able to do it via a custom Role (i.e. QTableWidgetItem::setData(myCommentRole, bool commentEnabled) ) if possible, but that's not really critical

Sean



This message has been scanned for malware by Forcepoint. www.forcepoint.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cellCommentIndicator.png
Type: image/png
Size: 2726 bytes
Desc: cellCommentIndicator.png
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20171120/9e0bd87e/attachment.png>


More information about the Interest mailing list