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. Text selections is causing custom formatting to be overwritten
Forum Updated to NodeBB v4.3 + New Features

Text selections is causing custom formatting to be overwritten

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.0k 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.
  • D Offline
    D Offline
    darkdescendant
    wrote on last edited by
    #1

    I am using a QTextEdit widget with a QSyntaxHighligher attached to do syntax highlighting. This is a great solution but I have run into an issue I can't seem to find any info on.

    It appears that text selection/highlighting in QTextEdit causes the formatting for the selected text to be replaced with the selection foreground and background colors. As soon as you remove the selection the formatting returns but while selected all my formatting is gone.

    Is there any way to make selection highlighting to respect the current format? Somehow change the highlighting format specifically so it blends with the text formatting and not replaces it?

    Thanx,
    joe

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      [quote author="darkdescendant" date="1285868796"]
      Is there any way to make selection highlighting to respect the current format? Somehow change the highlighting format specifically so it blends with the text formatting and not replaces it?
      [/quote]

      When you say current format, are you talking about italics and bold? Even if you use the QSyntaxHighlighter they are still retained. You can see the richtext/syntax highlighter demo that ships with Qt ...

      or are you talking about some other format?

      1 Reply Last reply
      0
      • D Offline
        D Offline
        darkdescendant
        wrote on last edited by
        #3

        What I mean is that things like background and foreground text colors are being replaced by the highilight colors. Bold and italic are still there but those are not the only two text properties that carry information in my app.

        1 Reply Last reply
        0
        • V Offline
          V Offline
          VC15
          wrote on last edited by
          #4

          I tried selecting a highlighted text in Eclipse and PSPad. It also loses its colors. Maybe it is a common behavior.
          Maybe there is a performance reason - replacing a color is easier than blending with it.
          Excuse that my post actually doesn't help with the problem.

          1 Reply Last reply
          0
          • ? This user is from outside of this forum
            ? This user is from outside of this forum
            Guest
            wrote on last edited by
            #5

            how about using these style attributes in a stylesheet?

            selection-color and selection-background-color

            would that solve your problem. I'm able to set my choice of colors here ...

            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