本文整理汇总了C++中QColor::setRgb方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::setRgb方法的具体用法?C++ QColor::setRgb怎么用?C++ QColor::setRgb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::setRgb方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintEvent
void VisualBoardSquare::paintEvent(QPaintEvent * e)
{
Super::paintEvent(e);
QPainter painter(this);
QColor c;
c.setRgb(255,255,255);
painter.setPen(c);
Ficha* f=tablero.consultar(fila,columna);
if(f)
{
QImage sourceImage=
f->getColor()==COLOR_BLANCO?
getIcono_ficha_blanca():getIcono_ficha_roja();
sourceImage=sourceImage.scaled(painter.device()->width(),painter.device()->height(),Qt::KeepAspectRatio);
QRect rect=sourceImage.rect();
QRect devrect(0,0,painter.device()->width(),painter.device()->height());
rect.moveCenter(devrect.center());
painter.drawImage(rect.topLeft(),sourceImage);
if(f->esDobleMovimiento())
{
QImage crownImage=
getIcono_corona().scaled(
painter.device()->width()/3,
painter.device()->height()/3,
Qt::KeepAspectRatio);
rect=crownImage.rect();
QRect devrect2(0,0,painter.device()->width(),painter.device()->height());
rect.moveCenter(devrect2.center());
painter.drawImage(rect.topLeft(),crownImage);
}
}
}
示例2: paintEvent
void fadeButton::paintEvent( QPaintEvent * _pe )
{
QColor col = m_normalColor;
if( m_stateTimer.elapsed() < FadeDuration )
{
const float state = 1 - m_stateTimer.elapsed() / FadeDuration;
const int r = (int)( m_normalColor.red() *
( 1.0f - state ) +
m_activatedColor.red() * state );
const int g = (int)( m_normalColor.green() *
( 1.0f - state ) +
m_activatedColor.green() * state );
const int b = (int)( m_normalColor.blue() *
( 1.0f - state ) +
m_activatedColor.blue() * state );
col.setRgb( r, g, b );
QTimer::singleShot( 20, this, SLOT( update() ) );
}
QPainter p( this );
p.fillRect( rect(), col );
int w = rect().right();
int h = rect().bottom();
p.setPen( m_normalColor.darker(130) );
p.drawLine( w, 1, w, h );
p.drawLine( 1, h, w, h );
p.setPen( m_normalColor.lighter(130) );
p.drawLine( 0, 0, 0, h-1 );
p.drawLine( 0, 0, w, 0 );
}
示例3: convertAttributesToColor
bool QtSkin::convertAttributesToColor(const QString& aName, const QXmlAttributes& theAttributes, QColor& aColor)
{
int redIndex=theAttributes.index("red");
int greenIndex=theAttributes.index("green");
int blueIndex=theAttributes.index("blue");
if(redIndex<0 || greenIndex<0 || blueIndex<0)
{
setErrorMessage("Invalid attributes for color "+aName);
return false;
}
else
{
int red, green, blue;
if(!convertStringToInteger(theAttributes.value(redIndex), red))
{
setErrorMessage("Invalid red: "+theAttributes.value(redIndex)+" for "+aName);
return false;
}
if(!convertStringToInteger(theAttributes.value(greenIndex), green))
{
setErrorMessage("Invalid green: "+theAttributes.value(greenIndex)+" for "+aName);
return false;
}
if(!convertStringToInteger(theAttributes.value(blueIndex), blue))
{
setErrorMessage("Invalid blue: "+theAttributes.value(blueIndex)+" for "+aName);
return false;
}
aColor.setRgb(red, green, blue);
}
return true;
}
示例4: plotSpectr
void PlotterWindow::plotSpectr(HyperCube *ptrCube, uint dataX, uint dataY)
{
quint16 Chnls = ptrCube->GetCountofChannels();
qint16* pSpectrValues = new qint16[Chnls];
try{ //если можем получить точку гиперкуба
ptrCube->GetSpectrumPoint(dataX, dataY,pSpectrValues); // записали в pSpectrValues из гиперкуба
QVector<double> xArr(Chnls), yArr(Chnls);
for (quint16 i = 0; i < Chnls; ++i )
{
xArr[i] = i;
yArr[i] = pSpectrValues[i];
}
QVector<double> sortedYArr;
sortedYArr = yArr;
qSort(sortedYArr);
if (sortedYArr.first() < minY )
minY = sortedYArr.first();
if (sortedYArr.last() > maxY )
maxY = sortedYArr.last();
QString grafName;
grafName.append("X:");
grafName.append(QString::number(dataX));
grafName.append(" Y:");
grafName.append(QString::number(dataY));
m_customPlot->setInteraction(QCP::iRangeDrag , true);
m_customPlot->setInteraction(QCP::iRangeZoom , true);
m_customPlot->legend->setVisible(true);
if (!m_hold)
m_customPlot->clearGraphs();
m_customPlot->addGraph();
if (m_customPlot->graphCount() == 1) // первый график всегда черного цвета, остальные - рандомные
m_customPlot->graph()->setPen(QPen(Qt::black));
else
{
QColor color;
int limit = 256;
int randR = qrand() % limit;
int randG = qrand() % limit;
int randB = qrand() % limit;
color.setRgb(randR,randG,randB);
m_customPlot->graph()->setPen(QPen(color));
}
m_customPlot->graph()->setName(grafName);
m_customPlot->graph()->setData(xArr,yArr);
m_customPlot->xAxis->setRange(xArr.first(),xArr.last());
m_customPlot->yAxis->setRange(minY,maxY);
m_customPlot->replot();
}catch(...){
m_customPlot->replot();
}
delete pSpectrValues;
}
示例5: detectEdgeImage
QImage edge_detector::detectEdgeImage(const QImage image, int kernel)
{
QImage destImage = QImage( image);
QRect rect = image.rect();
QColor qc;
int H = rect.height();
int W = rect.width();
int **a;
qreal gradient, gangle;
int r, g, b;
int maxg(0);
for (int y=0; y<H; y++) // y=1; y<H-1;
{
for (int x=0; x<W; x++) // x=1; x<W-1;
{
a = get_neighbor_pixels(image, x, y, 1, true);
edge_detect(a, kernel, &gradient, &gangle);
deleteArray(a, 3); //size of array allocated by get_neighbor_pixels is 3x3, 3 = (range=1)*2+1
if ((gangle >= -22.5 && gangle < 22.5) || (gangle >= 157.5 || gangle < -157.5))
{
r = 0;
g = 0;
b = 255;
}
else if ((gangle >= 22.5 && gangle < 67.5) || (gangle <= -112.5 && gangle > -157.5))
{
r = 0;
g = 255;
b = 0;
}
else if ((gangle >= 67.5 && gangle < 112.5) || (gangle <= -67.5 && gangle > -112.5))
{
r = 255;
g = 255;
b = 0;
}
else if ((gangle >= 112.5 && gangle < 157.5) || (gangle <= -22.5 && gangle > -67.5))
{
r = 255;
g = 0;
b = 0;
}
if (gradient > maxg)
maxg = gradient;
qc.setRgb((int)gradient & r, (int)gradient & g, (int)gradient & b);
destImage.setPixel( x, y, qc.rgba());
}
}
//printf("gangle = %f, maxg = %d\n", gangle, maxg);
return destImage;
}
示例6: updateNumLabel
void PicsSelectWidget::updateNumLabel()
{
QColor back;
switch (m_doc->getPicsWarning())
{
case CubeDoc::WARN_NOT_ENOUGH_PIECES: back.setRgb(255, 111, 114); break;
case CubeDoc::WARN_VERY_LITTLE_PIECES: back.setRgb(255, 194, 63); break;
case CubeDoc::WARN_NONE: back.setRgb(105, 255, 112); break;
}
m_countPalette->setColor(QPalette::Active, QPalette::Window, back);
m_countPalette->setColor(QPalette::Inactive, QPalette::Window, back);
m_numLabel->setPalette(*m_countPalette);
m_numLabel->setText(QString("%1 / %2").arg(m_currentGlobalCount).arg(m_currentBuildTilesCount));
}
示例7: DrawPlanet
void Planet::DrawPlanet(QPainter *QP)
{
QColor tempColor = QColor();
tempColor.setRgb(0,255,0,255);
QPen temppen;
temppen = QPen(tempColor);
QP->setPen(temppen);
if(PFocus)
{
QP->drawEllipse(QPoint(Location.x()+Location.width()/2,Location.y()+Location.height()/2),Location.width()-7,Location.height()-7);
}
QP->drawImage(Location,PlanetImg);
tempColor.setRgb(255,255,255,255);
temppen = QPen(tempColor);
QP->setPen(temppen);
QP->drawText(QPoint(Location.x()+Location.width()/2-7,Location.y()+Location.height()/2),QString::number(Population,10)); //Set back to population
}
示例8: slotFlashBlackoutIndicator
void App::slotFlashBlackoutIndicator()
{
QPalette pal;
QColor bg;
QColor fg;
pal = m_blackoutIndicator->palette();
bg = pal.color(QPalette::Background);
bg.setRgb(bg.red() ^ 0xff, bg.green() ^ 0xff, bg.blue() ^ 0xff);
pal.setColor(QPalette::Background, bg);
fg = pal.color(QPalette::Foreground);
fg.setRgb(fg.red() ^ 0xff, fg.green() ^ 0xff, fg.blue() ^ 0xff);
pal.setColor(QPalette::Foreground, fg);
m_blackoutIndicator->setPalette(pal);
}
示例9: mixColor
QColor Tools::mixColor(const QColor &color1, const QColor &color2)
{
QColor mixedColor;
mixedColor.setRgb( (color1.red() + color2.red()) / 2,
(color1.green() + color2.green()) / 2,
(color1.blue() + color2.blue()) / 2 );
return mixedColor;
}
示例10: add_preset_color
QColor add_preset_color(int which_color)
{
QColor color;
color.setRgb(preset_colors[which_color].red, preset_colors[which_color].green, preset_colors[which_color].blue, 255);
return (color);
}
示例11:
QColor
QMMLPainter::qcolor(const MathColor &mc) const {
QColor qc;
if (!mc.isTransparent()) {
qc.setRgb(mc.r(), mc.g(), mc.b());
}
return qc;
}
示例12: readColorEntry
QColor KConfigBase::readColorEntry(const char *pKey, const QColor *pDefault) const
{
QColor aRetColor;
int nRed = 0, nGreen = 0, nBlue = 0;
QString aValue = readEntry(pKey);
if(!aValue.isEmpty())
{
if(aValue.at(0) == '#')
{
aRetColor.setNamedColor(aValue);
}
else
{
bool bOK;
// find first part (red)
int nIndex = aValue.find(',');
if(nIndex == -1)
{
// return a sensible default -- Bernd
if(pDefault)
aRetColor = *pDefault;
return aRetColor;
}
nRed = aValue.left(nIndex).toInt(&bOK);
// find second part (green)
int nOldIndex = nIndex;
nIndex = aValue.find(',', nOldIndex + 1);
if(nIndex == -1)
{
// return a sensible default -- Bernd
if(pDefault)
aRetColor = *pDefault;
return aRetColor;
}
nGreen = aValue.mid(nOldIndex + 1, nIndex - nOldIndex - 1).toInt(&bOK);
// find third part (blue)
nBlue = aValue.right(aValue.length() - nIndex - 1).toInt(&bOK);
aRetColor.setRgb(nRed, nGreen, nBlue);
}
}
else
{
if(pDefault)
aRetColor = *pDefault;
}
return aRetColor;
}
示例13: color
QColor GLCDColors::color(QString name)
{
QColor color;
if (name == "red")
{
color.setRgb(255, 0, 0);
}
else if (name == "blue")
{
color.setRgb(0, 32, 255);
}
else if (name == "white")
{
color.setRgb(230, 230, 230);
}
else if (name == "green")
{
color.setRgb(32, 255, 32);
}
else if (name == "yellow")
color.setRgb(255,255,0);
else if (name == "brown")
color.setRgb(128,64,0);
else
{
color.setRgb(0, 32, 255);
}
return color;
}
示例14:
void Techni::slotHandleScheme23(){
QColor newColor;
newColor.setRgb(176,226,212); // mint green
myCanvas->setColor(newColor);
QPalette pal = ui->display->palette();
pal.setColor(QPalette::Window, newColor);
ui->display->setPalette(pal);
myCanvas->changeSelectedItemColorAndThickness();
}
示例15: painter
void B9Projector::drawStatusMsg()
{
if(mStatusMsg.size()==0 || this->isHidden())return;
QPainter painter(&mImage);
QColor color;
color.setRgb(127,0,0);
painter.setPen(color);
int leftOffset = 10;
int fontHeight = 10;
int bottomOffset = height() - 10;
int buffer = fontHeight/2.2;
painter.setFont(QFont("arial", fontHeight));
QRect bounds;
bounds = painter.boundingRect(leftOffset,bottomOffset-fontHeight,width(),fontHeight,Qt::TextDontClip,mStatusMsg);
color.setRgb(0,0,0);
painter.fillRect(leftOffset,bottomOffset-fontHeight-buffer,bounds.width(),fontHeight+2*buffer,color);
painter.drawText(QPoint(leftOffset,bottomOffset),mStatusMsg);
}