Important: Please read the Qt Code of Conduct -

Question about QColor and QColorDialog

  • Question about QColor and QColorDialog

    void MainWindow::on_pushButton_clicked()
        QColor color = QColorDialog::getColor(Qt::black, this, "Choose Pixel Color");
            qDebug() << color.convertTo(QColor::Spec QRgb);

    it outputs
    QColor(ARGB 1, 0, 1, 0)

    can i set the output to be RGB888 ? if yes how? :S i was in the docs for QColor but all i found was .toRgb but that did nothing

  • In QColor types, RGB = ARGB.
    If you want a QString like "#RRGGBB", you can use

    If you want an integer, the value of RGB24(888) equals the value of ARGB32 when alpha=0.
    So you can get it from:

    quint32 value = color.rgba() & 0xFFFFFF


    quint32 value = color.rgba()

Log in to reply