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. Updating a QGraphicsTextItem

Updating a QGraphicsTextItem

Scheduled Pinned Locked Moved General and Desktop
4 Posts 1 Posters 4.8k Views
  • 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.
  • I Offline
    I Offline
    icco
    wrote on last edited by
    #1

    I've been working with QGraphicsTextItems. I currently have the laid out in a scene, each depicting a physical page of text. Right now I'm overriding the keyReleaseEvent function to redistribute the text typed across all of the pages. The problem with this is that when I set the text with setPlainText, the cursor moves back to the beginning of the textitem that is set as the focus item for the scene.

    As you can imagine, this is problematic when typing, especially on another page instead of the one set to focus, it also makes the keyboard shortcuts for cutting and copying not work at all.

    Is there a way to set the text of a QGraphicsTextItem without it resetting the cursor / moving the cursor?

    1 Reply Last reply
    0
    • I Offline
      I Offline
      icco
      wrote on last edited by
      #2

      bump...

      1 Reply Last reply
      0
      • I Offline
        I Offline
        icco
        wrote on last edited by
        #3

        Is there any extra data I could give to help me get an answer? I really am stuck.

        1 Reply Last reply
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on last edited by
          #4

          If you use setPlainText(), the whole QTextItem will get cleared and all previous undo/redo info is lost, so the cursor moves to 0 position. If you use movePostion or setPosition, the cursor doesn't seem to move.

          So why not use insertText() and then use your logic to repaginate. I tried a quick example and this works.

          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