QToolTip background-color is not clipped with border radius
Asked Answered
T

1

6

I have styled my tooltips like this (not really that colors)

QToolTip {
    border: 1px solid blue;
    border-radius: 10px;
    background-color: red;
}

But the background is not clipped at the corners:

enter image description here

Why is it not clipped?

Trainor answered 24/8, 2016 at 10:20 Comment(0)
P
4

Two years after your question was asked, struggling with the same issue, using experiments and hard googling I came to the following:

  • You can't get what you want with css only, not with widgets
  • QToolTip is actually a QLabel
  • Implementing custom tooltip is a bit more job, but only a bit: setAttribute(Qt::WA_TranslucentBackground); + setMask() work fine, as well as other, simplier ways to implement widget transparency

At last, if you are really into it, recursively walking over widget's children and installing event filter could be a sufficient solution, smth like:

if (event->type() == QEvent::ToolTip) {
    QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
    // Your code here
    return true;
}

Easier it is if you don't wish to have those tooltips everywhere. Sometimes you already have to do something similar to apply complex CSS styles from files to dynamically created widgets, but anyway that's not a "codeless solution". Alas, couldn't find a better way up to now.

Pshaw answered 7/9, 2018 at 15:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.