Results 1 to 3 of 3

Thread: Can anyone give me a example on using QGraphicsScene::mouseMoveEvent?

  1. #1
    Join Date
    Jan 2010
    Posts
    22
    Thanks
    5

    Default Can anyone give me a example on using QGraphicsScene::mouseMoveEvent?

    Hello,

    Can anyone give me a example on using QGraphicsScene::mouseMoveEvent?

    My application is

    * myscene->addPixmap(QPixmap::fromImage(myimage));
    * ui->graphicsView->setScene(myscene);
    * ui->graphicsView->show();

    For me it seems no way to get mouse event on this displayed image. I want to draw lines on this displayed image.

    I also have the lines in my application.h

    protected:
    void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);


    Can anyone give me an example or tips? Thank you in advance!

  2. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Can anyone give me a example on using QGraphicsScene::mouseMoveEvent?

    Hi there!

    Have a look at the diagram-scene example: http://doc.trolltech.com/latest/grap...gramscene.html

    You should also consider creating a subclass of QGraphicsPixmapItem and reimplementing its mouse events instead of the scenes.

    That way you would hasslefree only get the events inside the item and in item coordinates. Depends on what you want to achieve..

    HIH

    Johannes

  3. The following user says thank you to JohannesMunk for this useful post:

    fulin (14th January 2011)

  4. #3
    Join Date
    Jan 2010
    Posts
    22
    Thanks
    5

    Default Re: Can anyone give me a example on using QGraphicsScene::mouseMoveEvent?

    Hi Johannes,

    Thank you very much! It is very helpful tip.

Similar Threads

  1. Hi all. I give up (not really, but yes, kind of)
    By tachoknight in forum Newbie
    Replies: 1
    Last Post: 4th December 2010, 02:57
  2. mouseMoveEvent problem in QGraphicsView/QGraphicsScene
    By Lendrick in forum Qt Programming
    Replies: 3
    Last Post: 23rd September 2010, 05:26
  3. QGraphicsScene::mouseMoveEvent Question
    By harakiri in forum Qt Programming
    Replies: 3
    Last Post: 3rd March 2008, 14:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.