Results 1 to 5 of 5

Thread: Mouse event on a QGraphicsItem that is not in it's own class

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2012
    Posts
    2
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Question Mouse event on a QGraphicsItem that is not in it's own class

    Let's say I create a QGraphicsItem (rectangle) in a QGraphicsScene (scene), without creating a class for the item:

    Constructur of Mainwindow (.cpp):
    Qt Code:
    1. ui->setupUi(this);
    2. scene = new QGraphicsScene(this);
    3. ui->graphicsView->setScene(scene);
    4. rectangle = scene->addRect(0,0,100,100);
    To copy to clipboard, switch view to plain text mode 

    Is there a way to overwrite a mouse click on the rectangle and make something happen, even if it is not in another class?
    What about showing a tooltip when hovering over it?

    I hope the question is clear and not completely redundant.
    Last edited by xzyerasu; 26th December 2012 at 18:52.

Similar Threads

  1. Ogre+qt mouse event (add object with mouse problem)
    By rimie23 in forum Qt Programming
    Replies: 7
    Last Post: 24th April 2012, 10:49
  2. Replies: 3
    Last Post: 7th January 2012, 08:38
  3. QGraphicsItem can't receive mouse leave/enter event
    By wshn13 in forum Qt Programming
    Replies: 1
    Last Post: 22nd June 2011, 08:32
  4. Do the layout class can receive the mouse event?
    By tszzp in forum Qt Programming
    Replies: 3
    Last Post: 23rd December 2009, 08:07
  5. can not get mouse double click event for QGraphicsItem
    By learning_qt in forum Qt Programming
    Replies: 2
    Last Post: 14th September 2009, 20:36

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.