Qt QColor获取颜色代码,如45653(0-65535)

Qt QColor获取颜色代码,如45653(0-65535),qt,qt4,qcolor,Qt,Qt4,Qcolor,我有一个简单的问题,但我还不能解决它 我想是这样的: QColor someColor = getColor(); 在此之后,我需要得到范围(0-65535)内的颜色代码,请注意,我不需要范围(0-255)内的颜色代码 那我该怎么办? 可能是这样的: someColor.get...() bool ok; qDebug() << someColor.name().replace("#", "").toUInt(&ok,16); QColor是3个字节(RGB)的组合,因

我有一个简单的问题,但我还不能解决它

我想是这样的:

QColor someColor = getColor();
在此之后,我需要得到范围(0-65535)内的颜色代码,请注意,我不需要范围(0-255)内的颜色代码

那我该怎么办? 可能是这样的:

someColor.get...()
bool ok;
qDebug() << someColor.name().replace("#", "").toUInt(&ok,16);

QColor是3个字节(RGB)的组合,因此您应该寻找从0到2^24-1[0,16777215]的颜色范围

你可以这样做:

someColor.get...()
bool ok;
qDebug() << someColor.name().replace("#", "").toUInt(&ok,16);
bool正常;

qDebug()QColor是3个字节(RGB)的组合,因此您应该寻找从0到2^24-1[0,16777215]的颜色范围

你可以这样做:

someColor.get...()
bool ok;
qDebug() << someColor.name().replace("#", "").toUInt(&ok,16);
bool正常;

qDebug()Qt已经提供了这样的功能。 请参阅文档和

上面说:

QRgb QColor::rgb() const
// Returns the RGB value of the color. The alpha value is opaque.

QRgb QColor::rgba() const
// Returns the RGB value of the color, including its alpha.

typedef QRgb
// An ARGB quadruplet on the format #AARRGGBB, equivalent to an unsigned int.
// The type also holds a value for the alpha-channel.

Qt已经提供了这样的功能。 请参阅文档和

上面说:

QRgb QColor::rgb() const
// Returns the RGB value of the color. The alpha value is opaque.

QRgb QColor::rgba() const
// Returns the RGB value of the color, including its alpha.

typedef QRgb
// An ARGB quadruplet on the format #AARRGGBB, equivalent to an unsigned int.
// The type also holds a value for the alpha-channel.