一、静态函数-API:

    1. // 弹出颜色选择对话框, 并返回选中的颜色信息
    2. /*
    3. 参数:
    4. - initial: 对话框中默认选中的颜色, 用于窗口初始化
    5. - parent: 给对话框窗口指定父对象
    6. - title: 对话框窗口的标题
    7. - options: 颜色对话框窗口选项, 使用默认属性即可, 一般不需要设置
    8. */
    9. [static] QColor QColorDialog::getColor(
    10. const QColor &initial = Qt::white,
    11. QWidget *parent = nullptr, const QString &title = QString(),
    12. QColorDialog::ColorDialogOptions options = ColorDialogOptions());
    1. // 构造函数
    2. QColor::QColor(Qt::GlobalColor color);
    3. QColor::QColor(int r, int g, int b, int a = ...);
    4. QColor::QColor();
    5. // 参数设置 red, green, blue, alpha, 取值范围都是 0-255
    6. void QColor::setRed(int red); // 红色
    7. void QColor::setGreen(int green); // 绿色
    8. void QColor::setBlue(int blue); // 蓝色
    9. void QColor::setAlpha(int alpha); // 透明度, 默认不透明(255)
    10. void QColor::setRgb(int r, int g, int b, int a = 255);
    11. int QColor::red() const;
    12. int QColor::green() const;
    13. int QColor::blue() const;
    14. int QColor::alpha() const;
    15. void QColor::getRgb(int *r, int *g, int *b, int *a = nullptr) const;