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 : controlling cursor width and color
Forum Updated to NodeBB v4.3 + New Features

QTextEdit : controlling cursor width and color

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 2 Posters 5.1k Views 4 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.
  • H Offline
    H Offline
    Harry123
    wrote on 10 Jan 2017, 15:10 last edited by Harry123 1 Oct 2017, 15:18
    #1

    My problems with the QTextEdit blinking cursor are :

    1. The cursor is invisible over some background colors (the solution would be to set it to the antithesis of the background color)
    2. I would like the cursor to be wider when in overwrite mode
    3. Sometimes when changing the QTextEdit color and font I can end up with the artifact of a phantom cursor left painted over the QTextEdit (the real cursor itself is also displayed and can be moved around)

    I have not found any way to control the cursor's width and color and would be thankful for any hints for that and for how to avoid phantom cursors.

    F 1 Reply Last reply 10 Jan 2017, 15:21
    0
    • H Harry123
      10 Jan 2017, 15:10

      My problems with the QTextEdit blinking cursor are :

      1. The cursor is invisible over some background colors (the solution would be to set it to the antithesis of the background color)
      2. I would like the cursor to be wider when in overwrite mode
      3. Sometimes when changing the QTextEdit color and font I can end up with the artifact of a phantom cursor left painted over the QTextEdit (the real cursor itself is also displayed and can be moved around)

      I have not found any way to control the cursor's width and color and would be thankful for any hints for that and for how to avoid phantom cursors.

      F Offline
      F Offline
      Flotisable
      wrote on 10 Jan 2017, 15:21 last edited by
      #2

      @Harry123
      have you read QTextEdit document?
      I find there is a method to set the curcor width

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Harry123
        wrote on 10 Jan 2017, 15:23 last edited by
        #3

        @Flotisable
        Yes, I missed this one - I will be testing it.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Flotisable
          wrote on 10 Jan 2017, 15:57 last edited by
          #4

          I find that set the color of the StyleSheet can change the color of the cursor

          1 Reply Last reply
          0
          • H Offline
            H Offline
            Harry123
            wrote on 11 Jan 2017, 11:18 last edited by Harry123 1 Nov 2017, 11:21
            #5

            @Flotisable

            QTextEdit::setCursorWidth works for the cursor width - thanks. It seems to need QTextEdit::update() to have immediate effect.

            QTextEdit::setStyleSheet("color:..." changes the cursor color, but unfortunately it also colors the frame border and may also color the text. There is a new draft for caret-color which unfortunately is not yet in the standard, although seems to be implemented in Firefox and also in Chrome.
            I wonder if I need to make a feature request for implementing caret-color.

            For the phantom cursor, something I do leaves a phantom cursor at the end of the text, which disappears after a full repaint. I would really like to avoid this artifact.

            F 1 Reply Last reply 11 Jan 2017, 12:19
            0
            • H Harry123
              11 Jan 2017, 11:18

              @Flotisable

              QTextEdit::setCursorWidth works for the cursor width - thanks. It seems to need QTextEdit::update() to have immediate effect.

              QTextEdit::setStyleSheet("color:..." changes the cursor color, but unfortunately it also colors the frame border and may also color the text. There is a new draft for caret-color which unfortunately is not yet in the standard, although seems to be implemented in Firefox and also in Chrome.
              I wonder if I need to make a feature request for implementing caret-color.

              For the phantom cursor, something I do leaves a phantom cursor at the end of the text, which disappears after a full repaint. I would really like to avoid this artifact.

              F Offline
              F Offline
              Flotisable
              wrote on 11 Jan 2017, 12:19 last edited by
              #6

              @Harry123
              for the text color, you can use QTextEdit's setTextColor method after set color of style sheet.
              for the frame border, maybe you can set border of style sheet.

              I think anything about widget color can be solved by using style sheet, so maybe you can read Qt Style Sheet if there is any problem about widget color.

              as for phantom cursor, can you show some image and more detail?sorry, I don't understand well about what you said.

              1 Reply Last reply
              1
              • H Offline
                H Offline
                Harry123
                wrote on 11 Jan 2017, 12:45 last edited by
                #7

                @Flotisable

                I already started doing that, but this is becoming a horrible mix of style-sheet overridden by commands such as setTextColor with nothing documented about which overrides which.
                Color in QTextEdit seems a bit of a mess. Maybe, as you said, better to stick to one only : either all or none style-sheet.
                The problem with style-sheets is that the latest CSS doesn't seem to be supported.

                For the phantom cursor, I'm still examining the problem.

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  Harry123
                  wrote on 12 Jan 2017, 16:16 last edited by Harry123 1 Dec 2017, 16:18
                  #8

                  Finally the all-CSS approach worked, avoiding all functions of QTextCharFormat or palette.

                  The following CSS tags worked for me : color, border-style, border-width, border-color, background-color.

                  Conclusion : Only use QTextEdit::setStyleSheet for changing the look - avoid all other functions like the plague.
                  I am disgusted with the amount of time that I wasted on this problem and the poor co-existence in QTextEdit of the style-sheet with all the other pertaining functions.

                  1 Reply Last reply
                  0

                  1/8

                  10 Jan 2017, 15:10

                  • Login

                  • Login or register to search.
                  1 out of 8
                  • First post
                    1/8
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved