khavq
khavq

Reputation: 41

How to customize a widget's QToolTip stylesheet

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"
    "}"));

Upvotes: 1

Views: 11564

Answers (1)

Denis Fatkulin
Denis Fatkulin

Reputation: 71

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);

Upvotes: 7

Related Questions