Q: Qt - [c++] toolTip padding gets lost when showing second time.
-
Hello!
I am using a QPushButton->setToolTip("...") with a padding defined in a css stylesheet.
This padding is eg: 10 pixel in size at each border.
This is shown fine, when i move the mouse over the element the first time.
But when moving out and in again, the padding is not shown anymore, and the text sticks to the border of the tooltip.
Any suggestions to preserve these tooltip paddings?
best regards, kevin_d
-
Hi,
Which version of Qt are you using ?
On which OS ?Please provide a minimal compilable example that shows this behavior.
-
I am using Qt 5.15.12 on Windows 11.
QString css = "QToolTip { font-size:24px; color:white; background-color:#808080; border:1px solid black; padding: 10px 10px 10px 10px; } " auto* button = new QPushButton(); button->setText("Click me"); buttons->setStylesheet(css);
-
@kevin_d This is not "minimal compilable example that shows this behavior"...
-
There is a bug that seems to describe the issue described in this thread:
https://bugreports.qt.io/browse/QTBUG-119752
Since @kevin_d did not state which Qt version, it is impossible to know whether we expect to see that documented bug in the version kevin is using or not.@kevin_d is using using Qt 5.15.12 , whereas the bug QTBUG-119752 is reported against Qt 6.5 (and the fix is not yet released? Am I reading the bug ticket right?). It seems possible that this is the same bug, but I don't know whether the Qt team would check the 5.15 branch and list it as affected if a bug is reported against 6.5.
I also noticed in the Qt bugtracker that when searching for tooltip bugs, the Windows OS is clearly a hotbed of these bugs (more than any other OS).
There must be something really tricky about how the underlying Windows API(s) for tooltip styles work, making it seemingly impossible for Qt to wrap and produce styled tooltips without bugs on Windows.
If QTBUG-119752 is not the cause of the original post here, then it would not surprise me if it is another windows Qt tooltip style bug (or a regression).
In that case, it would make sense to report it on the bugtracker.
To report it, a prerequisite would still be: a minimal compilable example. (I am echoing @SGaist and @jsulm on this point.)
@kevin_d , your provided code snippet doesn't even use
setToolTip
-
Hello!
Thanks for answering.
Yes, the snippet is wrong:
// can also contain button styles QString css = "QToolTip { font-size:24px; color:white; background-color:#808080; border:1px solid black; padding: 10px 10px 10px 10px; } " auto* button = new QPushButton(); button->setStyleSheet(css); button->setToolTip("This button is clickable."); button->setText("Click me");
Good, that I know it is not solvable atm.
kind regards, kevin
-
@kevin_d said in Q: Qt - [c++] toolTip padding gets lost when showing second time.:
Good, that I know it is not solvable atm.
QTBUG-119752 fixed the problem - it works fine for me with Qt 6.8
-
7/7