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. I have lines in Qt graphics UI. I want to highlight the line on mouse hover
Forum Updated to NodeBB v4.3 + New Features

I have lines in Qt graphics UI. I want to highlight the line on mouse hover

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 217 Views 2 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.
  • A Offline
    A Offline
    Ajit Patil
    wrote on last edited by
    #1

    0

    I have created the QGraphicsView in the Qt dialog. Added some lines in the QGraphicsView. I want to highlight the line on mouse hover. here not getting Object of line on mouse hover to highlight.

    bool QtdlUI::eventFilter(QObject* obj, QEvent* event)
    {
    if (event->type() == QEvent::MouseMove)
    {
    QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
    QPointF Inpos = mouseEvent->scenePosition();
    QGraphicsItem* Graphicsit = Gscene->itemAt(Inpos, ui.graphicsView->transform());
    }
    }
    I tried above code but getting QGraphicsItem null.

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

      Hi and welcome to devnet,

      Did you check the actual position value you're using with regard to the item position ?
      What is QtdlUI ?

      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
      • A Ajit Patil

        0

        I have created the QGraphicsView in the Qt dialog. Added some lines in the QGraphicsView. I want to highlight the line on mouse hover. here not getting Object of line on mouse hover to highlight.

        bool QtdlUI::eventFilter(QObject* obj, QEvent* event)
        {
        if (event->type() == QEvent::MouseMove)
        {
        QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
        QPointF Inpos = mouseEvent->scenePosition();
        QGraphicsItem* Graphicsit = Gscene->itemAt(Inpos, ui.graphicsView->transform());
        }
        }
        I tried above code but getting QGraphicsItem null.

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by
        #3

        @Ajit-Patil said in I have lines in Qt graphics UI. I want to highlight the line on mouse hover:

        I want to highlight the line on mouse hover

        One possible way to do so: Subclass your item and re-implement these two functions in your QGraphicsItem

        void hoverEnterEvent(QGraphicsSceneHoverEvent * event);
        void hoverLeaveEvent(QGraphicsSceneHoverEvent * event);
        

        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        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