QGraphicsScene doesn't enter drag event
Qt 4.3.2, MS VS 2005+integration
I derived my MyGraphicsScene from QGraphicsScene and reimplemented:
Code:
void MyGraphicsScene::dragEnterEvent(QGraphicsSceneDragDropEvent* event)
{
}
void MyGraphicsScene::dragLeaveEvent(QGraphicsSceneDragDropEvent* event)
{
}
also my QGraphicsView has DragMode RubberBandDrag enabled.
But while dragging the mouse cursor doesn't changes :( the dragging itself runs OK.
then I put breakpoints into both functions and realized that the application even doesn't enters them.
I searched this forum and google but didn't find an answer...
Thanks in advance
Re: QGraphicsScene doesn't enter drag event
RubberBandDrag has nothing to do with drag and drop. It's a flag that says that when you press and drag the mouse, items should get selected.
Re: QGraphicsScene doesn't enter drag event
QGraphicsScene drag enter event? you can grab direct from QGraphicsitem
on bool TextLayer::sceneEvent(QEvent *event)
Code:
/* TextLayer like QGraphicsTextItem */
bool TextLayer
::sceneEvent(QEvent *event
) {
/* drag here */
if ( event
->type
() == QEvent::GraphicsSceneDrop) { mount->txtControl()->processevent(event);
return true;
} else if (event
->type
() == QEvent::GraphicsSceneDragMove ) { /* QGraphicsSceneDragDropEvent *e = static_cast<QGraphicsSceneDragDropEvent *>(event); */
} else if (event
->type
() == QEvent::DragEnter ) { /*
*/
}
}
source on:
http://www.qt-apps.org/content/show....?content=80234
Re: QGraphicsScene doesn't enter drag event
I didn't subclassed any of QGraphicsitem..I don't need it) I just want to intercept the event on the Scene layer and change mouse cursor.
Re: QGraphicsScene doesn't enter drag event
I didn't subclassed any of QGraphicsItem..I don't need it) I just wonder why the Scene acts not like it's described in the assistant :(
Re: QGraphicsScene doesn't enter drag event
Quote:
Originally Posted by
Radagast
I just wonder why the Scene acts not like it's described in the assistant :(
At which point? For me it behaves exactly as described in Assistant...
Re: QGraphicsScene doesn't enter drag event
Quote:
Originally Posted by
Radagast
I didn't subclassed any of QGraphicsitem..I don't need it) I just want to intercept the event on the Scene layer and change mouse cursor.
dragEnterEvent and dragLeaveEvent are for Drag and Drop. You seem to be wanting normal mouse move events.
You can set the cursor for a QGraphicsView by calling QWidget::setCursor(), or for a QGraphicsItem with QGraphicsItem::setCursor(). Does that solve your problem?
Re: QGraphicsScene doesn't enter drag event
Excuse me, I didn't write the problem neatly... I meant "Drag and Drop" operations for items in the scene, as it's already implemented by Trolltech. You just need to set QGraphicsItem::ItemIsSelectable|QGraphicsItem::Ite mIsMovable and that's all, you can easily drag'n'drop one or many items at the scene. And I was sure that in the moment of start dragging item(s), QGraphicsScene::dragEnterEvent receives control and in that moment I wanna change the mouse cursor. And when the user drops item(s), I restore the cursor. Is it possible to implement without subclassing QGraphicsItem?
and the 2nd tiny question...also I need to mirror an item relative to a line (to create a simmetric copy of the item). What is the easiest way to implement that? I know, that the solution lies somewhere near item's QTransform, but yet I can't see a universal way :(
thanks in advance for all your help!
Re: QGraphicsScene doesn't enter drag event
OK, I think I know what you mean now. I don't think what you want is possible without subclassing QGraphicsItem because of the way the Graphics View Framework handles mouse events
Quote:
All mouse events are delivered to the current mouse grabber item. An item becomes the scene's mouse grabber if it accepts mouse events (see QGraphicsItem::acceptedMouseButtons()) and it receives a mouse press. It stays the mouse grabber until it receives a mouse release when no other mouse buttons are pressed.