[Solved] cursor problems in QTextEdit
-
wrote on 13 Jan 2011, 20:49 last edited by
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);
}
@ -
wrote on 13 Jan 2011, 22:19 last edited by
I don't understand. Can you describe you problem more clearly?
-
wrote on 14 Jan 2011, 06:56 last edited by
maybe you need ui->lineEdit->update();
-
wrote on 14 Jan 2011, 09:24 last edited by
How is this question different from the one you asked "here":http://developer.qt.nokia.com/forums/viewthread/3177/?
-
wrote on 14 Jan 2011, 09:26 last edited by
haha Andre you're so funny! are you monitor?
-
wrote on 14 Jan 2011, 14:08 last edited by
The problem is when i try to drop something out of the editing zone, my cursor is stuck, it's not flashing anymore except if i do another drag and drop in the editing area
-
wrote on 14 Jan 2011, 14:19 last edited by
Hm, do you have a small example that demonstrates the false behavior? This way we could look into the issue more thoroughly.
As a first question: what's the difference between isInEditionZone() with and without parameter?
-
wrote on 14 Jan 2011, 14:23 last edited by
Indeed. It is a bit hard to fix if we have no insight into your code. It would be ideal if your code would be in the form of a small, self contained, compilable example as suggested by Volker.
-
wrote on 14 Jan 2011, 14:42 last edited by
Solved by using the dragMoveEvent to define the dropzones. Thanks everyone.
-
wrote on 17 Jan 2013, 10:45 last edited by
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();
}@