Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. html in qtooltip::drawtext()
Qt 6.12 LTS is out! See what's new in the release blog

html in qtooltip::drawtext()

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 4 Posters 1.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    user4592357
    wrote on last edited by
    #1

    i have this code:

    	connect(pBtn, &QPushButton::clicked, [=]
    	{
    		const static QString sToolTip("Use the following:\n<hr>\n"
    			"...");
    		QToolTip::showText(pBtn->mapToGlobal(QPoint(0, 0)), sToolTip, pBtn);
    	});
    

    seems like the <hr> isn't recognized, it is just shown as <hr> in tooltip.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      According the documentation only richtext is supported.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        I think its not considered html for the tooltip label.
        try
        const static QString sToolTip("<html><head/><body><p>Use the following:</p><hr/><p><br/></p></body></html>"
        alt text

        1 Reply Last reply
        3
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          But <hr> is listed as part of richtext so should work

          Can you try using other tags like "Use the <b>following</b>" and see if they work?

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          2
          • U Offline
            U Offline
            user4592357
            wrote on last edited by
            #5

            what about a table? seems like setting border to it works, but i want the border to be thinner, but border-collapse: collapse; doesn't work

            mrjjM 1 Reply Last reply
            0
            • U user4592357

              what about a table? seems like setting border to it works, but i want the border to be thinner, but border-collapse: collapse; doesn't work

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              @user4592357 said in html in qtooltip::drawtext():

              border-collapse: collapse

              I dont think that tag is supported.

              Docs says
              table Table Supports the following attributes: border, bgcolor (Qt color names or #RRGGBB), cellspacing, cellpadding, width (absolute or relative), and height.

              regarding border width. 1 seems to be the smallest supported and it looks like
              alt text

              1 Reply Last reply
              0
              • U Offline
                U Offline
                user4592357
                wrote on last edited by
                #7

                would be nice if mine looked like that too.

                here's my code

                		const QString sToolTip(
                			"<html>"
                			"<body>"
                				"<table border=\"1\">"
                					"<caption>Header<caption>"
                					"<tr>"
                						"<td>...</tr>"
                				"</table>"
                			"</body>"
                			"</html>"
                		);
                

                now the look
                alt text

                1 Reply Last reply
                0
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #8

                  Hi
                  But your lines are so thin :)

                  My HTML ( drawn in word and just pasted and optimized but still most likely a bit verbose) update. cleaned up a bit.

                  <html><head/><body><table border="1" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px;" cellspacing="0" cellpadding="0"><tr><td width="130"><p><span style=" font-size:18pt;">aaaa</span></p></td><td width="130"/><td width="130"/><td width="130"/><td width="130"/></tr><tr><td><p><span style=" font-size:18pt;">bbbbb</span></p></td><td/><td/><td/><td/></tr></table></body></html>
                  
                  1 Reply Last reply
                  1
                  • U Offline
                    U Offline
                    user4592357
                    wrote on last edited by
                    #9

                    @mrjj
                    i'm on mobile now but will try that html.
                    another option i'm thinking of is showing a table widget. but i don't know at which position to show it (mouse click) and when and how to hide it?

                    mrjjM 1 Reply Last reply
                    0
                    • U user4592357

                      @mrjj
                      i'm on mobile now but will try that html.
                      another option i'm thinking of is showing a table widget. but i don't know at which position to show it (mouse click) and when and how to hide it?

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by mrjj
                      #10

                      @user4592357
                      Recreating tooltip feature is not that trivial.
                      https://code.woboq.org/qt5/qtbase/src/widgets/kernel/qtooltip.cpp.html
                      However, one can use event filter to catch if click outside and hide it.

                      Anyway, what is it you want to show in the tooltip ?
                      Small table or ?

                      ps. does work in tooltip. But this is not really a standard UX thing.
                      alt text

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt
                      • Unsolved