Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    3
    8
    174
    Loading More Posts
    • 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
      JulienMaille last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • J
          JulienMaille last edited by

          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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 2
            • J
              JulienMaille last edited by

              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 Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                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 Reply Quote 0
                • J
                  JulienMaille last edited by

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

                  mrjj 1 Reply Last reply Reply Quote 0
                  • mrjj
                    mrjj Lifetime Qt Champion @JulienMaille last edited by mrjj

                    @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 Reply Quote 1
                    • First post
                      Last post