[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);
}
@ -
I don't understand. Can you describe you problem more clearly?
-
maybe you need ui->lineEdit->update();
-
How is this question different from the one you asked "here":http://developer.qt.nokia.com/forums/viewthread/3177/?
-
haha Andre you're so funny! are you monitor?
-
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
-
I tried the update() nothing changed. @Andre this question came while trying to solve the other problem but it's not the same. At this point the other question is solved but a new problem shows.
-
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?
-
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.
-
Solved by using the dragMoveEvent to define the dropzones. Thanks everyone.
-
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();
}@