本文整理汇总了C++中QColor::getRgb方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::getRgb方法的具体用法?C++ QColor::getRgb怎么用?C++ QColor::getRgb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::getRgb方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setColours
void configDialog::setColours(QColor main, QColor peak) {
int r,g,b,opacity;
QString style;
mainGraph=main;
peakGraph=peak;
main.getRgb(&r, &g, &b, &opacity);
ui->mainColourPushbutton->setWindowOpacity(opacity);
style="background-color: rgba(" + QString::number(r) + ","
+ QString::number(g) + ","
+ QString::number(b) + ","
+ QString::number(opacity)
+ "); color: rgb(0,0,0,)";
ui->mainColourPushbutton->setStyleSheet(style);
peak.getRgb(&r, &g, &b, &opacity);
ui->peakColourPushbutton->setWindowOpacity(opacity);
style="background-color: rgba(" + QString::number(r) + ","
+ QString::number(g) + ","
+ QString::number(b) + ","
+ QString::number(opacity)
+ "); color: rgb(0,0,0,)";
ui->peakColourPushbutton->setStyleSheet(style);
}
示例2: return
bool
FX::haveContrast(const QColor &a, const QColor &b)
{
int ar,ag,ab,br,bg,bb;
a.getRgb(&ar,&ag,&ab);
b.getRgb(&br,&bg,&bb);
int diff = (299*(ar-br) + 587*(ag-bg) + 114*(ab-bb));
if (qAbs(diff) < 91001)
return false;
diff = (299*qAbs(ar - br) + 587*qAbs(ag - bg) + 114*qAbs(ab - bb)) / 300;
return (diff > 300);
}
示例3: QDialog
ColorFormatDlg::ColorFormatDlg( JuffPlugin* plugin, const QColor& color, QWidget* parent) : QDialog(parent) {
_ui.setupUi( this );
_plugin = plugin;
connect( _ui.buttonBox, SIGNAL(accepted()), SLOT(accept()) );
connect( _ui.buttonBox, SIGNAL(rejected()), SLOT(reject()) );
int r, g, b;
color.getRgb( &r, &g, &b );
_ui.btnHtml->setText( color.name() );
_ui.btnHex->setText( color.name().replace("#", "0x") );
_ui.btnHexSplitted->setText( QString().sprintf("0x%02hX, 0x%02hX, 0x%02hX", r, g, b) );
_ui.btnSplitted->setText( QString().sprintf("%i, %i, %i", r, g, b) );
_ui.buttonGroup->setId( _ui.btnHtml, 0 );
_ui.buttonGroup->setId( _ui.btnHex, 1 );
_ui.buttonGroup->setId( _ui.btnHexSplitted, 2 );
_ui.buttonGroup->setId( _ui.btnSplitted, 3 );
// _ui.btnHtml->setChecked( true );
int id = PluginSettings::getInt( plugin, "format", 0 );
QAbstractButton* btn = _ui.buttonGroup->button( id );
if ( btn != 0 ) {
btn->setChecked( true );
}
else {
_ui.btnHtml->setChecked( true );
}
}
示例4: updateBars
/**
* Update the gradient bar colors
*/
void ColorDialog::updateBars()
{
QColor col = color();
int r,g,b;
qreal h,s,v;
col.getRgb(&r,&g,&b);
col.getHsvF(&h,&s,&v);
if(h<0)
h = validhue_/360.0;
ui_->red->setColor1(QColor(0,g,b));
ui_->red->setColor2(QColor(255,g,b));
ui_->green->setColor1(QColor(r,0,b));
ui_->green->setColor2(QColor(r,255,b));
ui_->blue->setColor1(QColor(r,g,0));
ui_->blue->setColor2(QColor(r,g,255));
ui_->hue->setColorSaturation(s);
ui_->hue->setColorValue(v);
ui_->saturation->setColor1(QColor::fromHsvF(h,0,v));
ui_->saturation->setColor2(QColor::fromHsvF(h,1,v));
ui_->value->setColor1(QColor::fromHsvF(h,s,0));
ui_->value->setColor2(QColor::fromHsvF(h,s,1));
if(showalpha_) {
ui_->alpha->setColor1(QColor(r,g,b,0));
ui_->alpha->setColor2(QColor(r,g,b,255));
}
}
示例5: setValue
void ConfigurationVector::setValue(QString _key, QColor _value)
{
QString currentValue;
int red,green,blue;
QString redHex, greenHex, blueHex;
_value.getRgb(&red,&green,&blue);
redHex.setNum(red,16);
if (redHex.length() == 1)
{
redHex = "0" + redHex;
}
greenHex.setNum(green,16);
if (greenHex.length() == 1)
{
greenHex = "0" + greenHex;
}
blueHex.setNum(blue,16);
if (blueHex.length() == 1)
{
blueHex = "0" + blueHex;
}
currentValue = "C" + redHex + greenHex + blueHex;
setValue(_key, currentValue);
}
示例6: ScColor
void CMYKChoose::setColor2(int h, int s, bool ende)
{
ScColor tmp;
if (Farbe.getColorModel() == colorModelLab)
{
if (isHLC)
tmp = ScColor(MagentaSp->value(), static_cast<double>(h), static_cast<double>(s));
else
tmp = ScColor(CyanSp->value(), static_cast<double>(h), static_cast<double>(s));
}
else
{
QColor tm = QColor::fromHsv(qMax(qMin(359,h),0), qMax(qMin(255,255-s),0), 255-BlackComp, QColor::Hsv);
int r, g, b;
tm.getRgb(&r, &g, &b);
tmp.fromQColor(tm);
if (Farbe.getColorModel() == colorModelCMYK)
{
CMYKColor cmyk;
ScColorEngine::getCMYKValues(tmp, m_doc, cmyk);
tmp.setColor(cmyk.c, cmyk.m, cmyk.y, cmyk.k);
}
}
imageN.fill( ScColorEngine::getDisplayColor(tmp, m_doc) );
if ( ScColorEngine::isOutOfGamut(tmp, m_doc) )
paintAlert(alertIcon, imageN, 2, 2, false);
NewC->setPixmap( imageN );
Farbe = tmp;
if (ende)
setValues();
}
示例7: drawPalette
void KHueSaturationSelector::drawPalette( QPixmap *pixmap )
{
int xSize = contentsRect().width(), ySize = contentsRect().height();
QImage image( QSize( xSize, ySize ), QImage::Format_RGB32 );
QColor col;
int h, s;
uint *p;
col.setHsv( hue(), saturation(), colorValue() );
int _h, _s, _v, _r, _g, _b;
col.getHsv( &_h, &_s, &_v );
col.getRgb( &_r, &_g, &_b );
for ( s = ySize-1; s >= 0; s-- )
{
p = ( uint * ) image.scanLine( ySize - s - 1 );
for( h = 0; h < xSize; h++ )
{
switch ( chooserMode() ) {
case ChooserClassic:
default:
col.setHsv( 359 * h / ( xSize - 1 ), 255 * s / ( ( ySize == 1 ) ? 1 : ySize - 1 ), 192 );
break;
case ChooserHue:
col.setHsv( _h, 255 * h / ( xSize - 1 ), 255 * s / ( ( ySize == 1 ) ? 1 : ySize - 1 ) );
break;
case ChooserSaturation:
col.setHsv( 359 * h / ( xSize - 1 ), _s, 255 * s / ( ( ySize == 1 ) ? 1 : ySize - 1 ) );
break;
case ChooserValue:
col.setHsv( 359 * h / ( xSize - 1 ), 255 * s / ( ( ySize == 1 ) ? 1 : ySize - 1 ), _v );
break;
case ChooserRed:
col.setRgb( _r, 255 * h / ( xSize - 1 ), 255 * s / ( ( ySize == 1 ) ? 1 : ySize - 1 ) );
break;
case ChooserGreen:
col.setRgb( 255 * h / ( xSize - 1 ), _g, 255 * s / ( ( ySize == 1 ) ? 1 : ySize - 1 ) );
break;
case ChooserBlue:
col.setRgb( 255 * s / ( ( ySize == 1 ) ? 1 : ySize - 1 ), 255 * h / ( xSize - 1 ), _b );
break;
}
*p = col.rgb();
p++;
}
}
/*
if ( pixmap->depth() <= 8 )
{
const QVector<QColor> standardPalette = kdeui_standardPalette();
KImageEffect::dither( image, standardPalette.data(), standardPalette.size() );
}
*/
*pixmap = QPixmap::fromImage( image );
}
示例8: UpdateHtmDisplay
/*
* Update the QtHtmSublayer grid display after running the CLA.
*/
void QtFront::UpdateHtmDisplay()
{
QGridLayout *currGrid = (QGridLayout *)smiLayerGroup->layout();
QGridLayout *newHtmGrid = HtmDisplay->UnitGrid(objHtm);
HtmSublayer **sublayers = htm->GetSublayers();
unsigned int h = sublayers[0]->GetHeight();
unsigned int w = sublayers[0]->GetWidth();
unsigned int d = sublayers[0]->GetDepth();
QtUnit *colUnit = NULL;
QList<QtCell *> qtCells;
//QGridLayout *cellGrid = NULL;
QColor rgb[d+1];
int r[d+1], g[d+1], b[d+1];
for (unsigned int i=0; i<h; i++) {
for (unsigned int j=0; j<w; j++) {
colUnit = (QtUnit *)newHtmGrid->itemAtPosition(i, j)->widget();
//cellGrid = colUnit->GetCellGrid();
rgb[0] = colUnit->getBrushColor();
rgb[0].getRgb(&r[0], &g[0], &b[0]);
qtCells = colUnit->findChildren<QtCell *>();
for (unsigned int c=1; c<=d; c++) {
rgb[c] = qtCells.at(c-1)->getBrushColor();
rgb[c].getRgb(&r[c], &g[c], &b[c]);
}
colUnit =
(QtUnit *)currGrid->itemAtPosition(i, j)->widget();
colUnit->setBrushColor(QColor(r[0], g[0], b[0]));
qtCells = colUnit->findChildren<QtCell *>();
for (unsigned int c=1; c<=d; c++)
qtCells.at(c-1)->setBrushColor(
QColor(r[c], g[c], b[c])
);
}
}
QGridLayout *currPoolingGrid = (QGridLayout *)poolGroup->layout();
QGridLayout *newPoolingGrid = HtmDisplay->PoolUnitGrid(objHtm);
PoolingLayer *p = htm->GetPoolingLayer();
h = p->GetHeight();
w = p->GetWidth();
QColor rgbPool;
int rP, gP, bP;
for (unsigned int i=0; i<h; i++) {
for (unsigned int j=0; j<w; j++) {
colUnit =
(QtUnit *)newPoolingGrid->itemAtPosition(i, j)->widget();
rgbPool = colUnit->getBrushColor();
rgbPool.getRgb(&rP, &gP, &bP);
colUnit =
(QtUnit *)currPoolingGrid->itemAtPosition(i, j)->widget();
colUnit->setBrushColor(
QColor(rP, gP, bP));
}
}
}
示例9: htmlColor
QString BookmarksProtocol::htmlColor(const QColor &col)
{
int r, g, b;
col.getRgb(&r, &g, &b);
QString num;
num.sprintf("#%02X%02X%02X", r, g, b);
return num;
}
示例10:
void
FX::setColor(XRenderColor &xc, QColor qc)
{
uint a, r, g, b;
qc.getRgb((int*)&r, (int*)&g, (int*)&b, (int*)&a);
a = xc.alpha = (a | a << 8);
xc.red = (r | r << 8) * a / 0x10000;
xc.green = (g | g << 8) * a / 0x10000;
xc.blue = (b | b << 8) * a / 0x10000;
}
示例11: qMax
int
FX::contrastOf(const QColor &a, const QColor &b)
{
int ar,ag,ab,br,bg,bb;
a.getRgb(&ar,&ag,&ab);
b.getRgb(&br,&bg,&bb);
int diff = 299*(ar-br) + 587*(ag-bg) + 114*(ab-bb);
diff = (diff < 0) ? -diff : 90*diff/100;
int perc = diff / 2550;
diff = qMax(ar,br) + qMax(ag,bg) + qMax(ab,bb)
- (qMin(ar,br) + qMin(ag,bg) + qMin(ab,bb));
perc += diff/765;
perc /= 2;
return perc;
}
示例12: colorChanged
void msl::colorChanged(const QColor & color)
{
//Get RGB values of the current color
int r, g, b, h, s, v;
color.getRgb(&r, &g, &b);
color.getHsv(&h, &s, &v);
updateLEDs();
}
示例13: qtSelectorPressed
// Open color selector, and take color if it is valid
void ColorSelector::qtSelectorPressed()
{
QColor retColor = QColorDialog::getColor(QColor(mCurrentRGB[0],
mCurrentRGB[1],
mCurrentRGB[2]), this);
if (!retColor.isValid())
return;
retColor.getRgb(&mCurrentRGB[0], &mCurrentRGB[1], &mCurrentRGB[2]);
imposeColor(true, true);
}
示例14:
void KColorDialog::KColorDialogPrivate::setHtmlEdit(const QColor &col)
{
if (bEditHtml) return;
int r, g, b;
col.getRgb(&r, &g, &b);
QString num;
num.sprintf("#%02X%02X%02X", r, g, b);
htmlName->setText(num);
}
示例15: coloredText
QString coloredText(const QString &text, QColor color){
int r, b, g, a;
color.getRgb(&r,&g,&b, &a);
qDebug() << r << g << b;
QString c = "rgb(" + QString::number(r) + "," + QString::number(g) + "," + QString::number(b) + ")";
qDebug() << c;
QString res = "<pre style=\" font-weight: bold; color:" + c + ";\">" + text + " </pre>";
return res;
}