Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make indentation smaller in qt tooltips with html listing format?

Tags:

c++

html

qt

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?

like image 822
user1899020 Avatar asked Jun 02 '14 17:06

user1899020


People also ask

How do I indent text in Qt?

Indenting Text or Code | Qt Creator Manual Indenting Text or Code When you type text or code, it is indented automatically according to the selected text editor or code style options. Select a block to indent it when you press Tab. Press Shift+Tab to decrease the indentation.

How to indent in HTML?

HTML codes are used for the creation of a web page of text and visual content. In this article, we will touch upon how to indent in HTML. You can use an inline style in HTML to get all the results given above. If you want to see a style only once, you can check the example below. <p style = “margin-left: 40px”> This text is indented. </p>

How do I set the tool tip of a qwidget?

The simplest and most common way to set a widget's tool tip is by calling its QWidget::setToolTip () function (static tool tips). Then the tool tip is shown whenever the cursor points at the widget. We show how to do this with our application's tool buttons.

How to show tooltip text in HTML?

Example Explained. HTML: Use a container element (like <div>) and add the "tooltip" class to it. When the user mouse over this <div>, it will show the tooltip text. The tooltip text is placed inside an inline element (like <span>) with class="tooltiptext". CSS: The tooltip class use position:relative,...


1 Answers

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.

like image 137
rbaleksandar Avatar answered Oct 06 '22 18:10

rbaleksandar