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. Manipulating characters within a QTextDocument/QAbstractTextDocumentLayout
Forum Updated to NodeBB v4.3 + New Features

Manipulating characters within a QTextDocument/QAbstractTextDocumentLayout

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 391 Views 3 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.
  • TrilecT Offline
    TrilecT Offline
    Trilec
    wrote on last edited by Trilec
    #1

    Hi All,
    Im trying to find a creative solution to adding characters that are not editable to the outside of text blocks and potentially changing the "look" (UPPERCASE, ITALIC etc.) in a QTextEdit. The original text must stay the same as the user can switch to different views, however the printing should take into account the "view" settings .

    Use case: (User selects the "type of text" from a drop-down)

    • Normal
    • Brackets
    • Uppercase

    if "Bracket" is selected, the user is presented a margin indented start and end bracket [] with entry cursor set in the middle, the user cant remove the brackets but any text entry expands the brackets and when an enter key detected the next line is set to normal. eg: "TITLE: [ user text is here ]"

    If "Uppercase" is selected ,All text entry (until enter key) is "displayed" as uppercase,but if the type is changed to normal the original case is preserved. eg: "USER TEXT IS HERE" original "User Text is HERE"

    Edit*
    Seems the QAbstractTextDocumentLayout is one possible solution, but has anyone used this for this kind of use case and perhaps has examples or some advice?.

    As usual, appreciate any pointers in the right direction.

    If ts not in the computer it doesn't exist!...

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

      Hi,

      Are you looking to implement something like markdown ?

      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
      • TrilecT Offline
        TrilecT Offline
        Trilec
        wrote on last edited by Trilec
        #3

        @SGaist said in manipulating characters within a QTextDocument:

        markdown

        Yes it could be the internals, but the view is the area of interest for me , how to handle this
        I suppose syntax could be:
        <BLOCKUPPER>User Text HERE</BLOCKUPPER> : OUTPUT = USER TEXT HERE
        <BLOCKBRACKET>Editable Text Here</BLOCKBRACKET> : OUTPUT = [ Editable Text Here ]
        <BLOCKHEADING>NONEDITABLE-TITLE:</BLOCKHEADING><BLOCKBRACKET>Editable Text Here</BLOCKBRACKET> : OUTPUT = NONEDITABLE-TITLE: [ Editable Text Here ]

        ..or something like this, the key issue is the various BLOCK definitions have different behavior of whats editable and whats not, hope that clarifies.
        The docs start to get fuzzy around this, QTextDocument, QAbstractTextDocumentLayout , QTextBlock etc
        with no clear examples of adding new markups thus leaving me confused where to start with concepts on how to deal with adding non editable text.

        Looking at the forum there seems minimal information for QAbstractTextDocumentLayout.
        ..Has ANYONE got a pointer to examples of using this??
        QTextDocmentLayout and QPlaintTextEdit have some small private API usage but more advanced seems VERY hard to find
        cheers

        If ts not in the computer it doesn't exist!...

        1 Reply Last reply
        0
        • H Offline
          H Offline
          Haru
          wrote on last edited by
          #4

          In this book, there is explanation to subclass QAbstractTextDocumentLayout.
          https://www.amazon.co.jp/dp/B0D5BXJQBX?&linkCode=ll1&tag=multilinger19-22&linkId=6f566cae61fec736270f5086292ea57c&language=ja_JP&ref_=as_li_ss_tl

          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