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. QTextBlock with a prefix and a suffix
Forum Updated to NodeBB v4.3 + New Features

QTextBlock with a prefix and a suffix

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 1 Posters 758 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.
  • J Offline
    J Offline
    Jan-Willem
    wrote on last edited by
    #1

    I want to insert a QTextBlock which has a prefix and a suffix, just as in a QTextList but without a number or bullet or something. It has to be part of the QTextBlock and may not be removed with backspace/delete.

    A QTextList seems to put the prefix and suffix in the margins before and after the list item using a QTextLayout to draw on the paintDevice of the private QTextDocumentLayout. I have tried using this piece of code in my program, but I can't use the painDevice of the QTextDocumentLayout outside the QTextDocumentLayout.

    I'm also working on a QTextObjectInterface and have already had some result for the prefix, although it doesn't look very nice if the editable contents of the QTextBlock changes.

    So, I'm looking for some hints on the subject.

    • Is is possible to create a custom QTextList class with QTextListFormat::ListStyleUndefined and a prefix and suffix?
    • Is the QTextObjectInterface the way to go and does someone know a more detailed example than the Text Object Example?
    • Could QTextLayout::setPreeditArea be a better approach and is there some example of it's usage?
    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jan-Willem
      wrote on last edited by
      #2

      To be more exact, I want to place a "(" and a ")" at the beginning and the end of the QTextBlock. While I can place one of those with QTextLayout->setPreeditArea(0 , "("), it seems I can not place both of them. Also, While the "(" remains in place while deleting some of the characters, the textCursor can still be placed on position 0 where the preeditText is.

      Whem using a QTextList, a prefix and suffix can not be used with QTextListFormat::ListStyleUndefined.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jan-Willem
        wrote on last edited by
        #3

        Someone an idea or a better approach?

        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