Question about "Update" method.
I'm new around here and I was wonderin something that may sound silly.
How do I process something that happens onUpdate?
What do I mean with that is - I'm using SFML for doing some stuff and recently installed QT. If you guys know SFML and worked with it, you know how there is while(window.isOpen()) where you process some stuff that happen realtime.
Where do we actually process those stuff in QT? Like, for example:
-Moving an object with mouse (Usually graphics object with flag ItemIsMovable) and then storing the X and Y position of the object on every UPDATE in two variables. Then use those variables eventually.
Thanks in advance! =]
I don't SFML. Let me try to answer based on my understanding..Can you check MouseEvents like mousePressEvent(..) mouseMoveEvent(...) and MouseReleaseEvent(...) and check QMouseEvent class. This is pos(...) method which return the x and y position.
I presume you are using QGraphicsView?
while(window.isOpen()) is a polling mechanism.
Qt uses an event-driven mechanism instead. Whenever the object is moved, Qt automatically calls its mouseMoveEvent().
You need to subclass QGraphicsItem and reimplement mouseMoveEvent() to perform an action. Then, that action will be performed every time the object is moved.