QToolTip and QLineEdit
-
I am having using QLineEdit and QToolTip. Based upon certain conditions I need to change the background color of the tool tip to red. I have tried using setStyleSheet as below:
m_pGlobal->LaunchPage.latitudeSecVal->setStyleSheet("QLineEdit { color: black; background-color: lightgray; }"); m_pGlobal->LaunchPage.latitudeSecVal->setStyleSheet("QToolTip { color: white; background-color: red; }");
and the tooltip works but the QLineEdit style is changed. The background color is picked up from the parent.
I also tried using a QPalette as below:
QPalette palette = QToolTip::palette(); palette.setColor(QPalette::ToolTipBase, Qt::red); palette.setColor(QPalette::ToolTipText, Qt::white); QToolTip::setPalette(palette);
Using this doesn't affect the style of the QLineEdit but background color of the ToolTipBase should be red but it is not there. The text is the right color.
Is there something else I haven't tried?
-
Hi,
For the palette case, the style used can ignore it to ensure the application follows the OS standard.
As for the stylesheet, one issue is that the second call replaces what you set with the first one.
You need to set one stylesheet that contains all the changes you want to apply to that widget.