Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How to change color of user text in QLineEdit
Forum Updated to NodeBB v4.3 + New Features

How to change color of user text in QLineEdit

Scheduled Pinned Locked Moved Unsolved Qt for Python
5 Posts 5 Posters 21.7k 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.
  • S Offline
    S Offline
    sherief
    wrote on 18 Jun 2019, 17:34 last edited by sherief
    #1

    So I have a simple QLineEdit textbox that allows a user to login. The background color is dark grey so I wanted to make the user's text to be in white but I can't seem to figure out how to do this. In QtDesigner I have the option of changing font of text, but for some reason there's no option to change the text color. I've messed around with stylesheets but still can't get it.

    Any ideas?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      Denni
      wrote on 18 Jun 2019, 19:34 last edited by
      #2

      Text color in pyqt is generally the foreground color try setting that and see if that works for you within the QLineEdit

      madness... is like gravity, all takes is a little... push -- like from an unsolvable bug

      1 Reply Last reply
      1
      • D Offline
        D Offline
        DirkJ
        wrote on 22 Jun 2019, 16:32 last edited by
        #3

        Here the solution
        change colors if you like

                emailEdit.setStyleSheet("color: white;  background-color: black")
        
        D 1 Reply Last reply 22 Jun 2019, 17:08
        2
        • D DirkJ
          22 Jun 2019, 16:32

          Here the solution
          change colors if you like

                  emailEdit.setStyleSheet("color: white;  background-color: black")
          
          D Offline
          D Offline
          DirkJ
          wrote on 22 Jun 2019, 17:08 last edited by
          #4

          @DirkJ

          it is also possible to expand with selection color and selection background color

          emailEdit.setStyleSheet("color: blue; background-color: yellow; selection-color: yellow; selection-background-color: blue")

          rgb colors are possible too change color: in color: rgba(122,145,145)

          1 Reply Last reply
          0
          • R Offline
            R Offline
            Robh
            wrote on 31 Jan 2020, 20:57 last edited by
            #5

            In QC Designer, click on the QLineEdit box and in the properties, enable "autoFillBackground". Next, select the Palette property and in the pop up window, change the Text color to white.

            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