'How to make indentation smaller in qt tooltips with html listing format?
I am using html listing format to write tooltips in Qt as below.
widget->setTooltip(tr("<ul><li>First sentence</li></ul>"));
I found the indentation is too large. How can I set the indentation smaller?
Solution 1:[1]
Quite some time has passed but here is some information that might help you.
After doing some digging and also because Qt Designer was constantly replacing and screwing up my HTML that I wanted to use for my tooltip I looked closely and found the following:
<ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent:X;">
...
</ul>
with X being some number >= 0 (0 is basically the equivalent of left alignment). For the <li/> etc. you can use -qt-block-indent:X inside the style parameter of the tag.
That sad I was unable to make the indention less than it already is without loosing the bullet points. If you set -qt-list-indent:0 then you have (as mentioned above) a text on several lines with left alignment. If you set -qt-list-indent:1 you get the default behaviour which is what you want to change. I'm not much of a CSS/HTML person and also the Qt documentation is extremely lacking on this topic but I do believe decimal values are not allowed hence 1 is as low as you can get with indention. I've tried decimal values such as 0.5 or similar but I get the same result as if 1 was entered which leads to the conclusion that only integers can be used, it's a bug or this applies only to values between 0 and 1.
Here is an example of some HTML using this indention.
Solution 2:[2]
esmirnov's answer, posted as a comment on Dec 5. 2018, worked for me.
style="margin-left:15px; -qt-list-indent: 0;"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | rbaleksandar |
| Solution 2 | cigien |
