[英]Qt Windows: Rounded ToolTips
I need rounded tooltips in Qt5 + Windows. Rounded corners for tooltips cannot be set via stylesheet, the following stylesheet is not working:我需要 Qt5 + Windows 中的圆角工具提示。不能通过样式表设置工具提示的圆角,以下样式表不起作用:
QToolTip
{
font-family: Calibri;
font-size: 13pt;
border-radius: 0.5em;
...
}
I cannot override tootip events for widgets, because our application has too many places where tootips are shown.我无法覆盖小部件的 tootip 事件,因为我们的应用程序有太多显示 tootip 的地方。 I'm trying to do it in the following way:
我正在尝试通过以下方式进行操作:
int ThemeStyle::styleHint(StyleHint hint, const QStyleOption* option, const QWidget* widget, QStyleHintReturn* returnData) const
{
switch (hint)
{
case SH_ToolTip_Mask:
{
if (option)
{
if (QStyleHintReturnMask* mask = qstyleoption_cast<QStyleHintReturnMask*>(returnData))
{
static const int cornerRadius = 5;
QPainterPath path;
path.addRoundedRect(option->rect, cornerRadius, cornerRadius);
mask->region = QRegion(path.toFillPolygon().toPolygon()); // Unable to use QPolygonF ?
}
}
}
break;
//....
As a result, I get too angular corners:结果,我得到了 angular 个角:
Is there some global way to make smooth rounded tootips in Qt5?在 Qt5 中是否有一些全局方法可以制作平滑的圆形 tootips?
You're giving border radius in em
, try this style sheet:你在
em
中给出边界半径,试试这个样式表:
QToolTip {
border: 2px solid darkkhaki;
padding: 5px;
border-radius: 10px;
opacity: 200;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.