How to custom stylesheet QToolTip

陌路散爱 提交于 2019-12-25 16:37:57

问题


I'am using Qt4.8 to create a pushbutton,and then I using setStyleSheet function to set style for this button and tooltip. But this code only applied for button and tooltip is doesn't work. 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}"));

Please help me.


回答1:


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


来源:https://stackoverflow.com/questions/31979224/how-to-custom-stylesheet-qtooltip

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!