2

Please post some working example. The one below makes two borders: the rectangular background frame in black and a white outline with rounded edge. I can't believe it has not been done before.

app.setStyleSheet("QToolTip {
font-size:9pt;
color:white; padding:2px;
border-width:2px;
border-style:solid;
border-radius:20px;
background-color: black;
border: 1px solid white;}")
NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
alphanumeric
  • 17,967
  • 64
  • 244
  • 392

1 Answers1

6

The solution is to set a custom mask on tooltip widget. I can think of two ways of doing that:

  • Implement an own QStyle with a mask returned for QStyle::SH_ToolTip_Mask style hint. That is a generic way as default QToolTip would use this mask (example).

  • Create a custom QToolTip based class with a proper mask and then use QHelpEvent (QEvent::ToolTip) event of your widget to show it. It's not a generic solution as it requires to filter events on all widgets which need custom tooltip.

Oleg Shparber
  • 2,732
  • 1
  • 18
  • 19
  • `border-radius:5px;` still doesn't make it look good since it only rounds an outline and not the QToolTip's frame. The frame itself is unaffected by `border-radius:20px;` and it keeps its borders sharp. – alphanumeric Jul 23 '14 at 21:22
  • @Sputnix, I misread your question. I've updated my answer with the ways of achieving what you want. – Oleg Shparber Jul 23 '14 at 22:23
  • Thanks! The `QStyle` could be a probable solution. But the example is written in C++. And it is 50 pages long. I can't dedicate three days just to make the corners round. I will leave it as is. Not a big deal. – alphanumeric Jul 23 '14 at 22:42