Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. SVG tooltips in QGraphicsView
QtWS25 Last Chance

SVG tooltips in QGraphicsView

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 2.5k 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.
  • A Offline
    A Offline
    Ajp1989
    wrote on last edited by
    #1

    I have looked through the QtSvg docs and can't find any pointers on what I want to achieve. I have an SVG that I currently display within a QGraphicsView and that works fine. What I want however is to mimic firefox's behaviour (I believe it also part of the SVG standard) that when moused over the elements title is displayed as a tooltip.

    It is trivial to ascertain which QGraphicsSvgItem is under the mouse but I cant find any details about how you would find out more information such as the element within the SVG file. I have attached a sample SVG file and firefox gives the behaviour I want.

    Thanks for reading.
    !http://www.dur.ac.uk/a.j.poole/all.svg(Example SVG)!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

      No SVG experience to speak of, but from the docs your most likely chance seems to be QSvgRenderer::boundsOnElement - provided you know the item IDs.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Ajp1989
        wrote on last edited by
        #3

        Thanks for the tip. Think I am going to have to manually parse the file to get element IDs and titles. But a manual test appears to work.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Asperamanca
          wrote on last edited by
          #4

          SVG support is not Qt's strong suit, I'm sorry to say. Hope you find a solution that works for you.

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rhaschke
            wrote on last edited by
            #5

            Could you please post your solution? I have the same problem to solve.
            How can you know whether the mouse is over a particular svg node? Using bounding boxes is definitely not sufficient.

            1 Reply Last reply
            0
            • R Offline
              R Offline
              rhaschke
              wrote on last edited by
              #6

              Could you please post your solution? I have the same problem to solve.
              How can you know whether the mouse is over a particular svg node? Using bounding boxes is definitely not sufficient.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                Ajp1989
                wrote on last edited by
                #7

                I agree that bounding boxes are not ideal as elements may have unsual geometries but in my case it is just about acceptable so I didn't go further in finding a better solution. I would love to hear about one if you find it however.

                What I do is this:

                1. Parse svg to find element ID and title.
                2. calculate each elements bounds with QSvgRenderer::boundsOnElement
                3. on mouse events check if element bounds contains the mouse position
                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  Ajp1989
                  wrote on last edited by
                  #8

                  I agree that bounding boxes are not ideal as elements may have unsual geometries but in my case it is just about acceptable so I didn't go further in finding a better solution. I would love to hear about one if you find it however.

                  What I do is this:

                  1. Parse svg to find element ID and title.
                  2. calculate each elements bounds with QSvgRenderer::boundsOnElement
                  3. on mouse events check if element bounds contains the mouse position
                  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 Extensions
                  • Unsolved