How to round QToolTip corners with CSS and QT

坚强是说给别人听的谎言 提交于 2019-12-18 17:56:06

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/24920501/how-to-round-qtooltip-corners-with-css-and-qt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!