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. How can I reimplement hoverMoveEvent for different QGraphicsItem classes without copy/pasting code for each class
QtWS25 Last Chance

How can I reimplement hoverMoveEvent for different QGraphicsItem classes without copy/pasting code for each class

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 476 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.
  • J Offline
    J Offline
    JulienMaille
    wrote on last edited by
    #1

    I agree this may be more a c++ question than a Qt question and i'm sorry.
    Here is my problem, I want to subclass and reimplement a protected method for QGraphicsEllipseItem, QGraphicsPathItem, QGraphicsPolygonItem, QGraphicsRectItem, etc.
    Is there another solution than subclassing each of them one by one?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Depending on what you want to do, maybe an event filter could be simpler ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JulienMaille
        wrote on last edited by
        #3

        Thanks for your answer, I want to implement some tooltip on mouse hover. So idealy I would also need a few setters, not just the event reimplementation.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Might be a silly question but why not use setToolTip ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2
          • J Offline
            J Offline
            JulienMaille
            wrote on last edited by
            #5

            Hum, that's not silly at all.
            Well ... at first I didn't know it was so easy, so I went the reimplement way, and now I have some features I can't have just by using setToolTip

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              What features ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • J Offline
                J Offline
                JulienMaille
                wrote on last edited by
                #7

                Sorry for the late answer, I was sick.
                Main features are reimplementing shape() and mouse enter/leave events

                mrjjM 1 Reply Last reply
                0
                • J JulienMaille

                  Sorry for the late answer, I was sick.
                  Main features are reimplementing shape() and mouse enter/leave events

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

                  @JulienMaille
                  Hi
                  Mouse enter/leave can be handled by a event filter but
                  https://doc.qt.io/qt-5/qgraphicsellipseitem.html#shape
                  is a virtual function and it can only be handled in the class by override as its not seen by
                  an event filter.

                  Hope you are better now then :)

                  1 Reply Last reply
                  1

                  • Login

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