qtpyqthex

How to Convert Qcolor value to hex value?


I have implemented a QColor dialog box which opens on certain condition. To get the selected color after final selection I use the method selectedColor() which returns the value in QColor. When I print that value, it's like this:

<PyQt4.QtGui.QColor object at 0x01DD7880>

I want color value in hex value like this: #DFDFDF (for grey). If it's not hex, correct me.

Is there any function to convert that?

Any suggestions welcome.


Solution

  • You need to print selectedColor().name() to print the actual color value in hex. See the QColor Documentation