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. [SOLVED] How can i set the background color of listwidget item using rgb values?
QtWS25 Last Chance

[SOLVED] How can i set the background color of listwidget item using rgb values?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 5.5k 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.
  • L Offline
    L Offline
    Leon
    wrote on last edited by
    #1

    I want to set the background of my listwidget item.
    I don't want a simple blue so i don't want this one:

    @ item->setBackgroundColor("blue");@

    What i want is the rgb color: 170,170,255.
    How can i set the color to this rgb?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      You can use a QColor value.
      E.g. through "http://doc.qt.nokia.com/4.7/qcolor.html#setRgb":http://doc.qt.nokia.com/4.7/qcolor.html#setRgb

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Leon
        wrote on last edited by
        #3

        i had read this thread..
        @ item->setBackgroundColor(QColor::setRgb ( 170, 170, 255 ));@

        won't work.
        error: cannot call member function ‘void QColor::setRgb(int, int, int, int)’ without object

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          Of course you can not. setRgb is not a static method, after all. Use fromRgb if you do not want to use a QColor object instance that you can manipulate.
          This is really basic stuff, and very easy to find in the documentation file that you were already refered to. Please do a bit of digging yourself before asking.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            Leon
            wrote on last edited by
            #5

            Haven't seen this function Andre. All fine now.
            Thanks )

            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