Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. (Solved)The background-color of the QLineEdit
QtWS25 Last Chance

(Solved)The background-color of the QLineEdit

Scheduled Pinned Locked Moved Mobile and Embedded
10 Posts 5 Posters 30.8k 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.
  • H Offline
    H Offline
    hisong1988
    wrote on 20 Dec 2010, 09:01 last edited by
    #1

    Hello, everyone.

    I met a problem that I could not set the background-color of the QLineEdit as well as I put the QLineEdit on a widget.
    and the widget is put on the QMainWindow.

    Both I set the style sheet"background:white" and "background:white", the color of the LineEidt is the widget's background-color.

    any suggestions? thanks.

    best regards.
    hisong

    I am still searching for....

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vcsala
      wrote on 20 Dec 2010, 09:04 last edited by
      #2

      Are you working on maemo? I had similar problem in my application ("this thread":http://developer.qt.nokia.com/forums/viewthread/2360/), and it seems to be that this is a bug in Qt (I have not created the bug report in the bug tracker yet, as I have not had time to validate the issue and make it more specific).

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rugginoso
        wrote on 20 Dec 2010, 09:06 last edited by
        #3

        To match all the QLineEdits, you must use the class selector:
        @
        .QLineEdit
        @
        or
        @
        *[class~="QLineEdit"]
        @

        1 Reply Last reply
        0
        • M Offline
          M Offline
          milot.shala
          wrote on 20 Dec 2010, 09:18 last edited by
          #4

          or just:

          @

          lineEdit->setStyleSheet("QLineEdit{background: black;}");
          @

          1 Reply Last reply
          0
          • H Offline
            H Offline
            hisong1988
            wrote on 20 Dec 2010, 10:31 last edited by
            #5

            Thanks for all replies.

            I use the setStyleSheet funtion like
            @
            lineEdit->setStyleSheet("QLineEdit{background: white;}");
            @ to set the background-color white;
            but it doesn't work.

            and I try
            @
            QLineEdit {
            background: qradialgradient(cx:0, cy:0, radius: 1,
            fx:0.5, fy:0.5, stop:0 white, stop:1 rgba(0,190,0, 60%));
            border-radius: 9px;
            }
            @

            it worked.
            but the color is not what I need.

            I am still searching for....

            1 Reply Last reply
            0
            • F Offline
              F Offline
              Fuzzbender
              wrote on 20 Dec 2010, 10:56 last edited by
              #6

              Which OS is this happening?

              1 Reply Last reply
              0
              • H Offline
                H Offline
                hisong1988
                wrote on 20 Dec 2010, 11:46 last edited by
                #7

                I test the app on Nokia device 5230. The OS is s60v5.

                I am still searching for....

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  Fuzzbender
                  wrote on 20 Dec 2010, 12:04 last edited by
                  #8

                  I just tested this on latest Qt 4.7.x and it works. When you set the background color as a stylesheet, the lineEdit will lose the themed graphics (including borders etc) as theme graphics are coming from native side and QS60Style cannot make changes to those. So it is either stylesheeted background, borders etc. or theme graphics.

                  My code was:
                  @
                  QString lineEditStyle("QLineEdit {background: white;}");
                  QLineEdit *testLineEdit = new QLineEdit(this);
                  testLineEdit->setStyleSheet(lineEditStyle);
                  @

                  In case you can't get white background visible for the line edit with that code, what Qt version you have?

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    milot.shala
                    wrote on 20 Dec 2010, 12:47 last edited by
                    #9

                    It worked for me as well... are you trying to change the border-color? or the whole background?

                    1 Reply Last reply
                    0
                    • H Offline
                      H Offline
                      hisong1988
                      wrote on 21 Dec 2010, 04:32 last edited by
                      #10

                      I solved the problem from another aspect....It seems it is not the best way.

                      as I first set the background-image of the widget on the QMainWindow, and put the widget() on the QMainWindow, the background-color of QLineEdit was disable.

                      So I use QPainter to paint the image I use as the background-image on the widget, and then put the widget on the QMainWindow. and put the lineEdit's background-color white:
                      @
                      lineEdit->setStyleSheet("QLineEdit{background: white;}");
                      @

                      It worked.

                      I am still searching for....

                      1 Reply Last reply
                      0

                      8/10

                      20 Dec 2010, 12:04

                      • Login

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