Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Title attribute of html tag
QtWS25 Last Chance

Title attribute of html tag

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmllabelhtmltitle
8 Posts 4 Posters 2.2k Views
  • 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.
  • C Offline
    C Offline
    Cocojambo
    wrote on 6 Apr 2022, 01:38 last edited by
    #1

    I've checked list of all available tags/attributes but there is nothing about how to add a title into a string with html code. How to do it?

    Label {
            textFormat: Text.RichText
            text: "<span title=\"TITLE\">TEXT</span>"
        }
    
    J 1 Reply Last reply 8 Apr 2022, 01:41
    0
    • C Offline
      C Offline
      Cocojambo
      wrote on 7 Apr 2022, 22:06 last edited by
      #2

      Is it impossible at all? :[

      title.png

      1 Reply Last reply
      0
      • C Cocojambo
        6 Apr 2022, 01:38

        I've checked list of all available tags/attributes but there is nothing about how to add a title into a string with html code. How to do it?

        Label {
                textFormat: Text.RichText
                text: "<span title=\"TITLE\">TEXT</span>"
            }
        
        J Offline
        J Offline
        JKSH
        Moderators
        wrote on 8 Apr 2022, 01:41 last edited by JKSH 4 Aug 2022, 01:43
        #3

        @Cocojambo said in Title attribute of html tag:

        "<span title=\"TITLE\">TEXT</span>"
        

        Can you describe how you want to use the title attribute here?

        A title attribute of a span tag is very different from a title tag. The attribute is not displayed as part of the rich text.

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        C 1 Reply Last reply 8 Apr 2022, 02:45
        0
        • J JKSH
          8 Apr 2022, 01:41

          @Cocojambo said in Title attribute of html tag:

          "<span title=\"TITLE\">TEXT</span>"
          

          Can you describe how you want to use the title attribute here?

          A title attribute of a span tag is very different from a title tag. The attribute is not displayed as part of the rich text.

          C Offline
          C Offline
          Cocojambo
          wrote on 8 Apr 2022, 02:45 last edited by
          #4

          @JKSH Like it works for browsers - when I hover cursor above this span the title should appear. For Android app "hover" event should trigger by holding/clicking on it.

          Or maybe you could advise how to achieve next functionality: user can touch (click/hover) one word from a sentence and get some tooltip (pop up help) with some text (and custom elements if it's possible). Here is an example:

          IMG_20220408_053557.png

          J 1 Reply Last reply 8 Apr 2022, 14:32
          0
          • C Cocojambo
            8 Apr 2022, 02:45

            @JKSH Like it works for browsers - when I hover cursor above this span the title should appear. For Android app "hover" event should trigger by holding/clicking on it.

            Or maybe you could advise how to achieve next functionality: user can touch (click/hover) one word from a sentence and get some tooltip (pop up help) with some text (and custom elements if it's possible). Here is an example:

            IMG_20220408_053557.png

            J Offline
            J Offline
            JKSH
            Moderators
            wrote on 8 Apr 2022, 14:32 last edited by
            #5

            @Cocojambo said in Title attribute of html tag:

            @JKSH Like it works for browsers - when I hover cursor above this span the title should appear. For Android app "hover" event should trigger by holding/clicking on it.

            I see.

            The Qt rich text does not include tooltips, unfortunately.

            Or maybe you could advise how to achieve next functionality: user can touch (click/hover) one word from a sentence and get some tooltip (pop up help) with some text (and custom elements if it's possible).

            I can't think of an easy way of setting up tooltips for individual words/phrases. There is the QML ToolTip (https://doc.qt.io/qt-5/qml-qtquick-controls2-tooltip.html ) but you can only center it on an entire label, not on individual words.

            Perhaps you can open a feature request at https://bugreports.qt.io/ and post the link here.

            (Personally, I'm not sure if we should implement this as a title attribute... https://mrwweb.com/the-title-attribute-and-why-its-almost-useless/ )

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            C 1 Reply Last reply 8 Apr 2022, 20:53
            1
            • H Offline
              H Offline
              hskoglund
              wrote on 8 Apr 2022, 15:33 last edited by
              #6

              Even though (as @JKSH says) QTextEdit has no tooltip support, you could try implement something similar yourself, say like:

              do setAttribute(Qt::WA_Hover); on the QTextEdit window
              to receive QHoverEvents for that window
              get the QTextCursor for the coords of the hover
              try to select a word (if any) under that QTextCursor
              change the color of the selection
              create a QLabel on top of and close the QTextCursor (but on the line below so not to obscure the selected text)
              show what content you prefer in the QLabel
              loop back to start :-)

              1 Reply Last reply
              2
              • J JKSH
                8 Apr 2022, 14:32

                @Cocojambo said in Title attribute of html tag:

                @JKSH Like it works for browsers - when I hover cursor above this span the title should appear. For Android app "hover" event should trigger by holding/clicking on it.

                I see.

                The Qt rich text does not include tooltips, unfortunately.

                Or maybe you could advise how to achieve next functionality: user can touch (click/hover) one word from a sentence and get some tooltip (pop up help) with some text (and custom elements if it's possible).

                I can't think of an easy way of setting up tooltips for individual words/phrases. There is the QML ToolTip (https://doc.qt.io/qt-5/qml-qtquick-controls2-tooltip.html ) but you can only center it on an entire label, not on individual words.

                Perhaps you can open a feature request at https://bugreports.qt.io/ and post the link here.

                (Personally, I'm not sure if we should implement this as a title attribute... https://mrwweb.com/the-title-attribute-and-why-its-almost-useless/ )

                C Offline
                C Offline
                Cocojambo
                wrote on 8 Apr 2022, 20:53 last edited by
                #7

                @JKSH Thanks, I've added a new suggestion.

                @hskoglund Great advice. I also thought about WebView where I could do more "usual" for browser things but it seems too heavy for that simple task.

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  fcarney
                  wrote on 11 Apr 2022, 19:00 last edited by
                  #8

                  The tag support in Qt objects is really simplistic and nowhere near like a browser. If you want browser type html use webengine. I think webengine is pretty heavy and probably not what you want.

                  C++ is a perfectly valid school of magic.

                  1 Reply Last reply
                  0

                  3/8

                  8 Apr 2022, 01:41

                  topic:navigator.unread, 5
                  • Login

                  • Login or register to search.
                  3 out of 8
                  • First post
                    3/8
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved