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. Setting the cursor color
QtWS25 Last Chance

Setting the cursor color

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.6k Views
  • 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
    Dcqt
    wrote on last edited by
    #1

    Hi,
    I am using the following code to format my QTextEdit , but i am not able to change color of the cursor to white.

    please let me know how to change the color of the cursor to white.

    @
    QFont font("Arial",9,QFont::Courier,FALSE);
    setFont(font);
    setTextColor(Qt::white);
    QPalette pl = palette();
    pl.setColor(QPalette::Base,Qt::black);
    setPalette(pl);
    @

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      you mean the blinking text cursor not the mouse cursor right?
      Are you tied to using QPalette or can you also use stylesheets?

      Following should do what you want:
      @
      myTextEdit->setStyleSheet("QTextEdit {background-color: black; color : white; }");
      @

      but if you need to stick to QPalette you need to add the following line:
      @
      pl.setColor(QPalette::Text,Qt::white);
      @

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

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

        Thank for the reply.

        Thats working fine , there is one more problem whenever i copy paste some colored text to my QTextEdit from other page and press enter my future text in the window is also changing to same color.

        how to disable it.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          Dcqt
          wrote on last edited by
          #4

          Solved by using
          @ setTextColor(Qt::white); @
          again after pressing enter.

          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