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. MouseEvent ruined when ...
Forum Updated to NodeBB v4.3 + New Features

MouseEvent ruined when ...

Scheduled Pinned Locked Moved Solved General and Desktop
qgraphicssceneqmouseeventqgraphicsviewqgraphicsitemposition
4 Posts 1 Posters 1.5k 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.
  • W Offline
    W Offline
    Walux
    wrote on last edited by Walux
    #1

    Hi Qt Community ,

    I subclassed a QGraphicsView to gain access to slots , and especialy QMouseMoveEvent , my view's scene contains a subclassed QGraphicsItem that grabs my mouse events .

    To be precise , i coded my mouseMoveEvent to calculate the length between the cursor and my subclassed item , and it works just fine .

    But , when i configured my view to ensureVisible(myItem,x,y) , the calculations got ruined , and after several tests , i realized what's the problem.

    For it to be fixed , i want to catch my item's "view pos" ( or "widget pos" just to help being clear) because , ensure visible being active all the time with a QTimer , when the item goes to its margins , its item.pos() changes but he stands still in the view [Normal]

    So any ideas how to catch my item's "view pos" ?

    Thanks for your comprehension and sorry for the long post :b

    Taking things from beginning to end : That's my entertainment !

    1 Reply Last reply
    0
    • W Offline
      W Offline
      Walux
      wrote on last edited by Walux
      #2

      Omg , i just realized the topic isn't as ridiculous as it looks .
      The problem isn't in the item's pos nor view pos ...
      The problem is in the QMouseEvent ... (Someone : Wow how genius) but wait ...

      Since i'm using a QMouseEvent instead of a QGraphicsSceneMouseEvent , i catch the event->pos() , which is strictly relative to the view .
      So when the view "moves" with the effect of ensureVisible(item,x,y) while NOT moving my mouse , the event->pos() remains the same ! [Normal again]

      So to fix that , i want to catch my mouseEvent's scenePos , which i heard is only accessible when using QGraphicsSceneMouseEvent , but when i tried that ,the view didn't catch the event T-T

      Someone volunteer to help me get the QGraphicsSCeneMouseEvent working , I'll be grateful ;)

      Taking things from beginning to end : That's my entertainment !

      1 Reply Last reply
      0
      • W Offline
        W Offline
        Walux
        wrote on last edited by
        #3

        Should i subclass a QGraphicsScene ?

        Taking things from beginning to end : That's my entertainment !

        1 Reply Last reply
        0
        • W Offline
          W Offline
          Walux
          wrote on last edited by
          #4

          Yep , fixed !!

          Biggest achievement of ma layf.

          Topic->setAsSolvedPolicy(Qt::AlwaysTrue);

          Taking things from beginning to end : That's my entertainment !

          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