QT QColor,QString,QRgb 互转

废话不多说,直接上方法

    QColor c(255,0,255);
    //QColor >> QRgb(uint)
    QRgb mRgb = qRgb(c.red(),c.green(),c.blue());
    //QRgb(uint) >> QColor;
    QColor mColor = QColor(mRgb);
    //QRgb(uint) >> QString;
    QString mRgbStr = QString::number(mRgb,16);
    //QString >> unint >> QColor
    QColor color2(mRgbStr.toUInt(NULL,16));
    
    qDebug() << mRgb << mColor << mRgbStr;

 

你可能感兴趣的:(QT)