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. QTextEdit text change
Qt 6.11 is out! See what's new in the release blog

QTextEdit text change

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 872 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.
  • ultrabloxU Offline
    ultrabloxU Offline
    ultrablox
    wrote on last edited by
    #1

    Hi!
    I am trying to make customized text edit with some different block styles. The QTextDocument does not use frames - it is an array of blocks. The idea is, that each block has its user data, which defines type of block, and points to the item in linear array of my array of my_block_t.
    When I change a block text - I want to change corresponding my_block_t. When I delete a text block - I want to delete corresponding my_block_t. It is needed for building some complex structure over this array.
    I expected some clever signals from QTextEdit - like blockAdded(QTextBlock), blockRemoved(QTextBlock) and blockChanged(QTextBlock, QString old_data), and they could solved my problem. But I got only textChanged() and cursorPositionChanged(), and scanning all the document and rebuilding my whole structure after each textChanged is too expensive. How could I get needed events? At least how can I know delta in textChanged()?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Wouldn't QTextDocument::contentsChange and QTextDocument::findBlock be a starting point for your needs ?

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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