[Solved] cursor problems in QTextEdit
-
Hi, i redifined the dropEvent in my widget which inherit QTextEdit. I don't want to drop when out of a certain zone so i asked the dropevent to do nothing when out of that zone. It work fine but after that i lost my cursor i can still edit where i want but i can't see it until i do another drag and drop in the proper area.
Thanks the code is down
@
void QConsole::dropEvent ( QDropEvent * event)
{
if(!isInEditionZone(cursorForPosition(event->pos()).position()))
{
//Don't drop if out of the editing zone
return;
}
else if(!isInEditionZone())
{
//Execute un drop à l'ancienne position aussi
QTextCursor cur = textCursor();
cur.setPosition(oldPosition);
setTextCursor(cur);
}
//Execute un drop normal
QTextEdit::dropEvent(event);
}
@ -
How is this question different from the one you asked "here":http://developer.qt.nokia.com/forums/viewthread/3177/?
-
Just to make the solution obvious to future readers, what you have to do is simply redefine mouseMoveEvent to accept the event, like in the "Drop Site example":http://harmattan-dev.nokia.com/docs/platform-api-reference/xml/daily-docs/libqt4/draganddrop-dropsite-droparea-cpp.html:
@
void DropArea::dragMoveEvent(QDragMoveEvent *event)
{
event->acceptProposedAction();
}@