I have a qtablewidget. There are certain cells (qtablewidgetitem) in this table that need to show error message via qtooltip. I wish to change the background color of tooltip of each cell so as to highlight the tooltip message better. How can it be done ?
Asked
Active
Viewed 3,138 times
2 Answers
2
Probably the best way is the use of style sheets. You can set any text colors/background colors and text style that way.
Depending on your QT version, see the documentation:

meCHAoT
- 336
- 3
- 9
-
1Thanks a lot! Though an exhaustive one, the above documentation was of good help. I added following code to add customized tooltip to my qtablewidget => ui.ansTable->setStyleSheet("QToolTip{border: 2px solid orange; padding: 5px; border-radius: 3px; opacity: 200;}"); where ui.ansTable is a qtablewidget. – Nishant Kumar Dec 10 '15 at 09:32
2
you can use QtoolTip static methodes to update the palette :
QPalette palette = QToolTip::palette();
palette.setColor(QPalette::ToolTipBase,QColor("#F6F6F6")); // light grey
palette.setColor(QPalette::ToolTipText,QColor("#706F6F"));//dark grey for text
QToolTip::setPalette(palette);

Donald Duck
- 8,409
- 22
- 75
- 99

Nabil
- 41
- 3
- 10