本文整理汇总了C++中KoColor::toQColor方法的典型用法代码示例。如果您正苦于以下问题:C++ KoColor::toQColor方法的具体用法?C++ KoColor::toQColor怎么用?C++ KoColor::toQColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KoColor
的用法示例。
在下文中一共展示了KoColor::toQColor方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mouseMoveEvent
void KisColorPatches::mouseMoveEvent(QMouseEvent *event)
{
event->ignore();
KisColorSelectorBase::mouseMoveEvent(event);
if(event->isAccepted())
return;
if (!(event->buttons() & Qt::LeftButton))
return;
if ((event->pos() - m_dragStartPos).manhattanLength()
< QApplication::startDragDistance())
return;
KoColor koColor;
if(!colorAt(m_dragStartPos, &koColor))
return;
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
QColor color = koColor.toQColor();
mimeData->setColorData(color);
mimeData->setText(color.name());
drag->setMimeData(mimeData);
drag->exec(Qt::CopyAction);
event->accept();
}
示例2: hsvComparison
/*compares c1 and c2 based on HSV.
c1 < c2, returns -1
c1 = c2, returns 0
c1 > c2, returns 1 */
int hsvComparison(const KoColor& c1, const KoColor& c2) {
QColor qc1 = c1.toQColor();
QColor qc2 = c2.toQColor();
if (qc1.hue() < qc2.hue()) return -1;
if (qc1.hue() > qc2.hue()) return 1;
// hue is the same, ok let's compare saturation
if (qc1.saturation() < qc2.saturation()) return -1;
if (qc1.saturation() > qc2.saturation()) return 1;
// oh, also saturation is same?
if (qc1.value() < qc2.value()) return -1;
if (qc1.value() > qc2.value()) return 1;
// user selected two similar colors
return 0;
}
示例3: getColorFromConverter
QColor KisVisualColorSelectorShape::getColorFromConverter(KoColor c){
QColor col;
KoColor color = c;
if (m_d->displayRenderer) {
color.convertTo(m_d->displayRenderer->getPaintingColorSpace());
col = m_d->displayRenderer->toQColor(c);
} else {
col = c.toQColor();
}
return col;
}
示例4: slotDrawLine
void KisBrightnessContrastConfigWidget::slotDrawLine(const KoColor &color)
{
QColor colorNew = color.toQColor();
int i = (colorNew.red() + colorNew.green() + colorNew.blue())/3 ;
QPixmap pix = m_page->curveWidget->getBasePixmap();
QPainter p(&pix);
p.setPen(QPen(Qt::black, 1, Qt::SolidLine));
p.drawLine(i,0,i,255);
QString label = "x:";
label.insert(2,QString(QString::number(i)));
p.drawText(i,250,label);
m_page->curveWidget->setPixmap(pix);
}
示例5: mousePressEvent
void KisColorPatches::mousePressEvent(QMouseEvent *event)
{
KoColor koColor;
if(!colorAt(event->pos(), &koColor))
return;
KisColorSelectorBase::mousePressEvent(event);
if(event->isAccepted())
return;
updateColorPreview(koColor.toQColor());
if (event->button() == Qt::LeftButton)
m_dragStartPos = event->pos();
}
示例6: drawContents
void KoColorSlider::drawContents( QPainter *painter )
{
QPixmap checker(8, 8);
QPainter p(&checker);
p.fillRect(0, 0, 4, 4, Qt::lightGray);
p.fillRect(4, 0, 4, 4, Qt::darkGray);
p.fillRect(0, 4, 4, 4, Qt::darkGray);
p.fillRect(4, 4, 4, 4, Qt::lightGray);
p.end();
QRect contentsRect_(contentsRect());
painter->fillRect(contentsRect_, QBrush(checker));
if( !d->upToDate || d->pixmap.isNull() || d->pixmap.width() != contentsRect_.width()
|| d->pixmap.height() != contentsRect_.height() )
{
KoColor c = d->minColor; // smart way to fetch colorspace
QColor color;
const quint8 *colors[2];
colors[0] = d->minColor.data();
colors[1] = d->maxColor.data();
KoMixColorsOp * mixOp = c.colorSpace()->mixColorsOp();
QImage image(contentsRect_.width(), contentsRect_.height(), QImage::Format_ARGB32 );
if( orientation() == Qt::Horizontal ) {
for (int x = 0; x < contentsRect_.width(); x++) {
qreal t = static_cast<qreal>(x) / (contentsRect_.width() - 1);
qint16 colorWeights[2];
colorWeights[0] = static_cast<quint8>((1.0 - t) * 255 + 0.5);
colorWeights[1] = 255 - colorWeights[0];
mixOp->mixColors(colors, colorWeights, 2, c.data());
c.toQColor(&color);
for (int y = 0; y < contentsRect_.height(); y++)
image.setPixel(x, y, color.rgba());
}
}
else {
for (int y = 0; y < contentsRect_.height(); y++) {
qreal t = static_cast<qreal>(y) / (contentsRect_.height() - 1);
qint16 colorWeights[2];
colorWeights[0] = static_cast<quint8>((t) * 255 + 0.5);
colorWeights[1] = 255 - colorWeights[0];
mixOp->mixColors(colors, colorWeights, 2, c.data());
c.toQColor(&color);
for (int x = 0; x < contentsRect_.width(); x++)
image.setPixel(x, y, color.rgba());
}
}
d->pixmap = QPixmap::fromImage(image);
d->upToDate = true;
}
painter->drawPixmap( contentsRect_, d->pixmap, QRect( 0, 0, d->pixmap.width(), d->pixmap.height()) );
}
示例7: setBorderColor
void SimpleTableWidget::setBorderColor(const KoColor &koColor)
{
fillBorderButton(koColor.toQColor());
}