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. Strange QTextDocument behavior

Strange QTextDocument behavior

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.4k 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.
  • R Offline
    R Offline
    reactive
    wrote on last edited by
    #1

    My Windows desktop app monitors QTextDocument's contentsChange(int,int,int) method. If you type a letter into a blank document, that method announces 0 characters deleted and 1 inserted - which is the expected behavior. However, if you paste any text at the beginning of the document, it announces that ALL + 1 of the characters have been deleted and that all have been inserted.

    For example:
    If the document contains "abc" and you paste "123" at the beginning it announces 4 deleted and 6 inserted.

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      Yup,
      Very understandable. If you load a file, you just can't write to the beginning of the file. The file will be in sequence. So to "paste" the letters you want the file needs to be stored in RAM, cleared from driver and rewritten from RAM.
      Only when appending the data to the end of the file you will get the 3 chars added.
      greetz

      Greetz, Jeroen

      1 Reply Last reply
      0
      • R Offline
        R Offline
        reactive
        wrote on last edited by
        #3

        Jeroentje, QTextDocument is not a file. It's used by text components. Why would the behavior of pasting a single letter at the beginning be different from typing one?

        Typing a single letter before "abc" results in 0 deleted 1 added.
        Pasting a single letter before "abc" results in 4 deleted 4 added.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DerManu
          wrote on last edited by
          #4

          You should file a bug report, as this doesn't seem like the intended behaviour, also judging from the documentation of the signal.

          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