如何自定义样式表 QToolTip [英] How to custom stylesheet QToolTip

查看:65
本文介绍了如何自定义样式表 QToolTip的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Qt4.8 创建一个按钮,然后我使用 setStyleSheet 函数为这个按钮和工具提示设置样式.但是此代码仅适用于按钮和工具提示不起作用.这是我的代码

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;

这个->

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

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

请帮帮我.

推荐答案

您需要为 QToolTip 添加样式表.例如:

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

这篇关于如何自定义样式表 QToolTip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆