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. Best way to format text in this specific case (overlapping highlighting)?
Qt 6.11 is out! See what's new in the release blog

Best way to format text in this specific case (overlapping highlighting)?

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

    Hi everyone!

    I am making a custom text editor with more complex formatting than I am used so I have a quick question. There are two types of keywords and I want my editor to highlight each keyword type in a different color. So far so good, that's easy. Now I also want it to highlight the whole sentence with a specific color depending on the type of keyword it contains, as well as the whole paragraph.

    My question is can I begin by adding a format range for the whole paragraph, then go sentence by sentence and highlight those, then go word by word and highlight those ON TOP of the previous format ranges? Or do I have to do something like below, where each "break" in formatting is its own format range:
    f03854ca-c3fa-4bcb-b940-be198c0ec2cf-image.png

    What I want, instead of having 5 format ranges like in the above image, is to have only 3. Is that possible?

    What is the easiest way to accomplish what I need?

    Thank you very much!

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

      Hi,

      How your doing your highlighting currently ?

      From the top of my head it should be doable. I would go in the order you just presented so that each style is apply on top of the previous one.

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

        Thank you so much for replying! I actually tried to do it this way when I had just started using QT and was unable to so I wanted to confirm I wasn't doing it wrong before attempting again. It worked now. Thank you so much!

        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