I need rounded tooltips in Qt5 + Windows. Rounded corners for tooltips cannot be set via stylesheet, the following stylesheet is not working:
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. 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:
Is there some global way to make smooth rounded tootips in Qt5?
You're giving border radius in
em
, try this style sheet: