How to customize a widget's QToolTip stylesheet

10.6k Views Asked by At

I am using Qt4.8 to create a pushbutton, I'm also using setStyleSheet function to set style for this button and a tooltip. But the stylesheet is only applied to the button, not the tooltip.

This is my code:

QPushButton *status_label;

this->cellGUI.status_label->setStyleSheet(QString::fromUtf8(
    "QPushButton{"
        "color:#E6E6E6;"
        "font-weight:bolder;"
        "font-family:tahoma;"
        "font-size:6px;"
        "background-color:rgb(255,153, 0)"
    "}"
    "QPushButton::QToolTip{"
        "color:#2E2E2E;"
        "background-color:#CCCCCC;"
        "border:none"
    "}"));
1

There are 1 best solutions below

0
On

You need add style sheet for QToolTip. Ex.:

QString style = QString(
    "QPushButton {"
    // StyleSheet for your push button
    "    background: blue;"
    "}"
    "QToolTip {"
    // StyleSheet for tool tip
    "    background: red;"
    "}"
    );

this->cellGUI.status_label->setStyleSheet(style);