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. How to get the background colour of a QLineEdit?

How to get the background colour of a QLineEdit?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 991 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.
  • V Offline
    V Offline
    Vadi2
    wrote on last edited by
    #1

    I'd like to colour the text in my QLineEdit - but I also need the colours to adapt to dark themes. How can I tell the background colour of a QLineEdit, so I can adapt my colours appropriately?

    1 Reply Last reply
    0
    • YunusY Offline
      YunusY Offline
      Yunus
      wrote on last edited by
      #2

      @Vadi2 Hi
      What do you mean about adapting to dark themes? Not clear to me

      1 Reply Last reply
      0
      • YunusY Offline
        YunusY Offline
        Yunus
        wrote on last edited by
        #3

        @Vadi2 If you need only the background color you can do it using the below code:

        QLineEdit* bg = new QLineEdit();
        bg->setStyleSheet("QLineEdit {background-color: black;}");

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

          I don't need to set it, I need to get it's value. If you're using dark mode on macOS or a dark theme on Linux, the widget will be dark - how can I find that out programmatically?

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Vadi2 said in How to get the background colour of a QLineEdit?:

            how can I find that out programmatically?

            Then you should take a look at QWidget:palette

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            1

            • Login

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