PDA

View Full Version : Reimplementing way items move in QGraphicsScene/QGraphicsView



pssss
19th October 2010, 12:53
I want to implement a time line similar to what video editors have. The time line itself would be a subclass of QGraphicsView. The problem is that I want the rectangles (i.e. short sequence of videos) to only move sideways and not in any direction like the ItemIsMovable flag does.

I'm pretty confused and I'm not sure where I should reimplement the mouse events to make it so only a change in the x position of the mouse causes a movement of the rectangle when the mouse button is pressed. I don't know if I have to reimplement them in QGraphicsScene, QGraphicsView or on the QGraphicsItem themselves. Also, I'm not sure if I have to reimplement mouse move events, press, release or all of them.

I would like to also make the rectangles resizable but that's a different question and I'll make a new thread when I get there.

Thanks in advance.

pssss
22nd October 2010, 13:28
Ok, I got it working now. For anyone with the same problem. I reimplemented mouseMoveEvent() in a QGraphicsItem subclass and just make the item move with the mouse.