Home > other >  Novice: consult about QGraphicsScene and QGraphicsItem mouse events
Novice: consult about QGraphicsScene and QGraphicsItem mouse events

Time:11-10

Recently in learning, Qt is a part of a project is similar to the function of drawing, from the toolbox graphics first, and then draw, primitive can be moved at the same time, drag and drop, the attribute editor, etc., now I have my own class scene MyScene MyItem inherited from the QGraphicsScene own object class diagram metaclass inherited from QGraphicsItem, now I have a mouse events MyScene on the implementation method of class MousePressEvent used the mouse to click on the scene when loading Item. MyItem MousePressEvent class has the mouse events for the Item that has been generated on the scene class choice, but like to capture mouse events can only be MyScene class, cannot be MyItem capture, want to ask each master, how can you make my figure metaclass corresponding mouse events, or any other way to get the scenario I already use the mouse to choose the figure of yuan, kid sister new to Qt, many of them don't quite understand, hope to get your advice,

CodePudding user response:

Ha ha is a girl look QT with example is the thing you want to see below  images: QQ screenshots pinyin unnamed. JPG

CodePudding user response:

I also do a similar project, give a website, there are detailed explanations, http://qt-project.org/doc/qt-4.8/graphicsview-diagramscene.html

CodePudding user response:

Scenario has captured the event, but not for distribution to your item, not distributed to the cause of the item is due to the wrong detection area to event cannot be issued, you look at the boundary of the item in your shape function limit right,

CodePudding user response:

Hello, I met the same problem with you, the custom of the item can not receive custom scene to distribute the event object, how do you solve?
  • Related