QColor 和 int 互转

画图(https://gitee.com/sonichy/HTYPaint)需要保存颜色设置

参考:https://blog.csdn.net/snowdream86/article/details/5273757

int intColor = color.blue() << 16 | color.green() << 8 | color.red();

QColor MainWindow::IntToColor(int intColor)
{
    int red = intColor & 255;
    int green = intColor >> 8 & 255;
    int blue = intColor >> 16 & 255;
    return QColor(red, green, blue);
}

你可能感兴趣的:(Qt,Qt)