1、官方自带
Qt官方自带的QColorDialog类提供了一个指定颜色的对话框部件。
#include <QColorDialog>
QColor i = QColorDialog::getColor(Qt::red, this,
tr("颜色对话框"),
QColorDialog::ShowAlphaChannel);
2、自定义
但是好多开源项目都使用了自定义控件Qt Color Widgets。
https://gitlab.com/mattia.basaglia/Qt-Color-Widgets
C++使用方法:
1.pro文件
LIBS += -L$${DESTDIR} #lib path
LIBS += "QtColorWidgets-Qt52.lib"
INCLUDEPATH += ../color_widgets/include/
INCLUDEPATH += ../color_widgets/include/QtColorWidgets/
2.cpp源文件
#include "color_dialog.hpp" void Designer::on_actionColor_triggered() { color_widgets::ColorDialog dlg; connect(&dlg, &color_widgets::ColorDialog::colorSelected, this, &Designer::color_changed); dlg.exec(); } void Designer::color_changed(QColor color) { int r, g, b, a; color.getRgb(&r, &g, &b, &a); color.getHsv(&r, &g, &b, &a); }
https://github.com/pencil2d/pencil
https://github.com/douzhongqiang/EasyCanvas
https://github.com/caryoscelus/rainynite-studio
https://github.com/caryoscelus/Qt-Color-Widgets
------
https://github.com/frankosterfeld/qtkeychain
独立于平台的Qt API,用于安全存储密码。