Best clickable widget for color swatch?

  • I am looking for a widget for display a color swatch. I need to set the
    color to display and receive a signal when it's clicked.

    I can't seem to find an existing QWidget that does both. Just want to
    make sure there's indeed no such canned one before I build my own.


  • Hi Stephen,

    How about "QColorDialog":
    Is this what you are lookinf for?


  • You mean you are looking for a label that displays the color and when clicked, displays the QColorDialog?

  • Yes, I need a color label that responds to clicks. And brings up the color picker dialog. Thanks.

  • should not be hard to build on yourself
    just derive from QLabel, overwrite mouseClickEvent() and calls QColorDialog::getColor.
    Then call setbackgrounfdColor for the label.

    PS: all functions are just logical names, I did not look up the correct ones in the docs.

  • I am going to build my own. Just want to know I am not reinventing the wheel. :)


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.