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. Mouseover in Graphics View Framework
Qt 6.11 is out! See what's new in the release blog

Mouseover in Graphics View Framework

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 2.0k Views 1 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello,
    I'd like to have an image in the scene that is visible when the mouse pointer is inside its area and invisible otherwise.

    I tried to put the image in a QGraphicsPixmapItem and setOpacity(0.0), but the item doesn't receive hoverEnterEvents any more after that (it does receive them if I set the opacity to some other value like 0.01).

    What defines the area for mouseover events in items? If it was defined by shape() I could reimplement it, but it doesn't seem the case.
    Can something invisible get hoverEnterEvents?

    Also an item doesn't get an hoverEnterEvent() on show() when the pointer is over it (conversely a QLabel (outside of the scene) get an enterEvent() on show() when the pointer is over it).
    Is there a way to make it happen except checking isUnderMouse() and emulating the hoverEnterEvent() every time I show() it?

    Thanks,
    Nando

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rschaub
      wrote on last edited by
      #2

      you can manually create and send events using "sendEvent()":http://qt-project.org/doc/qt-4.8/qcoreapplication.html#sendEvent or "postEvent()":http://qt-project.org/doc/qt-4.8/qcoreapplication.html#postEvent

      alternatively, you could reimplement said events on your view and manually check whether the mouse has entered one of your invisible items, since afaik any item that is set to invisible won't receive any events.

      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