Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] cursor problems in QTextEdit
Qt 6.11 is out! See what's new in the release blog

[Solved] cursor problems in QTextEdit

Scheduled Pinned Locked Moved General and Desktop
11 Posts 5 Posters 7.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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);
    }
    @

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      I don't understand. Can you describe you problem more clearly?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mohsen
        wrote on last edited by
        #3

        maybe you need ui->lineEdit->update();

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          How is this question different from the one you asked "here":http://developer.qt.nokia.com/forums/viewthread/3177/?

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mohsen
            wrote on last edited by
            #5

            haha Andre you're so funny! are you monitor?

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

                  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?

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on last edited by
                    #9

                    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.

                    1 Reply Last reply
                    0
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #10

                      Solved by using the dragMoveEvent to define the dropzones. Thanks everyone.

                      1 Reply Last reply
                      0
                      • I Offline
                        I Offline
                        ihaveajob
                        wrote on last edited by
                        #11

                        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();
                        }@

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved