Please nominate your Qt Champions for 2021!

[SOLVED] QColorDialog

  • Hello guys

    I've seen "QColorDialog": documentation and I would like to show in a widget, permanently, the colour box with the colour slider. Is this possible? I've read through qcolordialog.cpp but cannot find where this widget is created. I'd prefer this than showing a permanent dialog.

    Any ideas? Thanks

  • You can call show on it, and with setting the proper windows flags you can remove all the window styling you don't want.

  • Building a color picker is actually a straightforward process your own application could benefit significantly by tailoring it to your specific needs. The one, provided by Qt dates back to the last century, and I myself would never use it outside of a quick testing scenario.

    Just draw a rect, fill it with varying colors in a loop according to its current dimensions, create a signal that gets the click coordinates and extrapolates out of those the color values based on the picker size and connect that to your setColor() or something slot in the parent widget.

  • Ok, thanks guys. Both work!

Log in to reply