本文整理汇总了C++中QColor::hsv方法的典型用法代码示例。如果您正苦于以下问题:C++ QColor::hsv方法的具体用法?C++ QColor::hsv怎么用?C++ QColor::hsv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColor
的用法示例。
在下文中一共展示了QColor::hsv方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawColoredArc
void QwtPainter::drawColoredArc(QPainter *painter, const QRect &rect,
int peak, int arc, int interval, const QColor &c1, const QColor &c2)
{
int h1, s1, v1;
int h2, s2, v2;
#if QT_VERSION < 0x040000
c1.hsv(&h1, &s1, &v1);
c2.hsv(&h2, &s2, &v2);
#else
c1.getHsv(&h1, &s1, &v1);
c2.getHsv(&h2, &s2, &v2);
#endif
arc /= 2;
for ( int angle = -arc; angle < arc; angle += interval)
{
double ratio;
if ( angle >= 0 )
ratio = 1.0 - angle / double(arc);
else
ratio = 1.0 + angle / double(arc);
QColor c;
c.setHsv( h1 + qRound(ratio * (h2 - h1)),
s1 + qRound(ratio * (s2 - s1)),
v1 + qRound(ratio * (v2 - v1)) );
painter->setPen(QPen(c, painter->pen().width()));
painter->drawArc(rect, (peak + angle) * 16, interval * 16);
}
}
示例2: mixedColor
/*!
Mixes two colors \a c1 and \a c2 to a new color.
*/
QColor QPlatinumStyle::mixedColor(const QColor &c1, const QColor &c2) const
{
int h1,s1,v1,h2,s2,v2;
c1.hsv(&h1,&s1,&v1);
c2.hsv(&h2,&s2,&v2);
return QColor( (h1+h2)/2, (s1+s2)/2, (v1+v2)/2, QColor::Hsv );
}
示例3: drawFocusIndicator
/*!
Draw a dotted round circle, if !isReadOnly()
\param painter Painter
*/
void QwtDial::drawFocusIndicator(QPainter *painter) const
{
if ( !isReadOnly() )
{
QRect focusRect = contentsRect();
const int margin = 2;
focusRect.setRect(
focusRect.x() + margin,
focusRect.y() + margin,
focusRect.width() - 2 * margin,
focusRect.height() - 2 * margin);
QColor color = colorGroup().color(QColorGroup::Base);
if (color.isValid())
{
int h, s, v;
color.hsv(&h, &s, &v);
color = (v > 128) ? Qt::gray.dark(120) : Qt::gray.light(120);
}
else
color = Qt::darkGray;
painter->save();
painter->setBrush(Qt::NoBrush);
painter->setPen(QPen(color, 0, Qt::DotLine));
painter->drawEllipse(focusRect);
painter->restore();
}
}
示例4: drawSegment
void BatteryStatus::drawSegment( QPainter *p, const QRect &r, const QColor &topgrad, const QColor &botgrad, const QColor &highlight, int hightlight_height ) {
int h1, h2, s1, s2, v1, v2, ng = r.height(), hy = ng*30/100, hh = hightlight_height;
topgrad.hsv( &h1, &s1, &v1 );
botgrad.hsv( &h2, &s2, &v2 );
for ( int j = 0; j < hy-2; j++ ) {
p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1),
v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) );
p->drawLine( r.x(), r.top()+hy-2-j, r.x()+r.width(), r.top()+hy-2-j );
}
for ( int j = 0; j < hh; j++ ) {
p->setPen( highlight );
p->drawLine( r.x(), r.top()+hy-2+j, r.x()+r.width(), r.top()+hy-2+j );
}
for ( int j = 0; j < ng-hy-hh; j++ ) {
p->setPen( QColor( h1 + ((h2-h1)*j)/(ng-1), s1 + ((s2-s1)*j)/(ng-1),
v1 + ((v2-v1)*j)/(ng-1), QColor::Hsv ) );
p->drawLine( r.x(), r.top()+hy+hh-2+j, r.x()+r.width(), r.top()+hy+hh-2+j );
}
}
示例5: qGray
QColor
PrettyPopupMenu::calcPixmapColor()
{
KConfig *config = KGlobal::config();
config->setGroup("WM");
QColor color = QApplication::palette().active().highlight();
// QColor activeTitle = QApplication::palette().active().background();
// QColor inactiveTitle = QApplication::palette().inactive().background();
QColor activeTitle = config->readColorEntry("activeBackground", &color);
QColor inactiveTitle = config->readColorEntry("inactiveBackground", &color);
// figure out which color is most suitable for recoloring to
int h1, s1, v1, h2, s2, v2, h3, s3, v3;
activeTitle.hsv(&h1, &s1, &v1);
inactiveTitle.hsv(&h2, &s2, &v2);
QApplication::palette().active().background().hsv(&h3, &s3, &v3);
if ( (kAbs(h1-h3)+kAbs(s1-s3)+kAbs(v1-v3) < kAbs(h2-h3)+kAbs(s2-s3)+kAbs(v2-v3)) &&
((kAbs(h1-h3)+kAbs(s1-s3)+kAbs(v1-v3) < 32) || (s1 < 32)) && (s2 > s1))
color = inactiveTitle;
else
color = activeTitle;
// limit max/min brightness
int r, g, b;
color.rgb(&r, &g, &b);
int gray = qGray(r, g, b);
if (gray > 180) {
r = (r - (gray - 180) < 0 ? 0 : r - (gray - 180));
g = (g - (gray - 180) < 0 ? 0 : g - (gray - 180));
b = (b - (gray - 180) < 0 ? 0 : b - (gray - 180));
} else if (gray < 76) {
r = (r + (76 - gray) > 255 ? 255 : r + (76 - gray));
g = (g + (76 - gray) > 255 ? 255 : g + (76 - gray));
b = (b + (76 - gray) > 255 ? 255 : b + (76 - gray));
}
color.setRgb(r, g, b);
return color;
}
示例6: font
ClusterPalette::ClusterPalette(QColor backgroundColor,QWidget* parent,KStatusBar * statusBar, const char* name, WFlags fl )
: QVBox( parent, name, fl ),doc(0L),mode(IMMEDIATE),isInSelectItems(false),isUpToDate(true),backgroundColor(backgroundColor),statusBar(statusBar),isInUserClusterInfoMode(false)
{
//Set the palette color
setPaletteBackgroundColor(backgroundColor);
setPaletteForegroundColor(white);
iconView = new QIconView(this, "ClusterPalette");
QFont font( "Helvetica",8);
iconView->setFont(font);
iconView->setFrameStyle(QFrame::NoFrame);
iconView->setArrangement(QIconView::LeftToRight);
iconView->setResizeMode(QIconView::Adjust);
iconView->setPaletteBackgroundColor(backgroundColor);
iconView->setHScrollBarMode(QScrollView::AlwaysOff);
iconView->setVScrollBarMode(QScrollView::AlwaysOff);
int h;
int s;
int v;
backgroundColor.hsv(&h,&s,&v);
if(s <= 80 && v >= 240 || (s <= 40 && v >= 220)) iconView->setPaletteForegroundColor(black);
else iconView->setPaletteForegroundColor(white);
iconView->setSelectionMode(QIconView::Extended);
iconView->setItemsMovable(false);
iconView->setSpacing(4);
QFontInfo fontInfo = QFontInfo(QFont());
iconView->setGridX(fontInfo.pixelSize() * 2);
iconView->setGridY(15);
iconView->arrangeItemsInGrid();
//Deal with the sizes
setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5,(QSizePolicy::SizeType)5));
//Set the legend in the good language
languageChange();
//Signal and slot connection
connect(iconView,SIGNAL(contextMenuRequested(QIconViewItem* ,const QPoint&)),this, SLOT(slotRightPressed(QIconViewItem*)));
connect(iconView,SIGNAL(selectionChanged()),this, SLOT(slotClickRedraw()));
connect(iconView,SIGNAL(mouseButtonPressed(int,QIconViewItem* ,const QPoint&)),this, SLOT(slotMousePressed(int,QIconViewItem*)));
connect(iconView,SIGNAL(onItem(QIconViewItem*)),this, SLOT(slotOnItem(QIconViewItem*)));
}
示例7: QColorGroup
QPalette::QPalette( const QColor &button, const QColor &background )
{
data = new QPalData;
Q_CHECK_PTR( data );
data->ser_no = palette_count++;
QColor bg = background, btn = button, fg, base, disfg;
int h, s, v;
bg.hsv( &h, &s, &v );
if ( v > 128 ) { // light background
fg = Qt::black;
base = Qt::white;
disfg = Qt::darkGray;
} else { // dark background
fg = Qt::white;
base = Qt::black;
disfg = Qt::darkGray;
}
data->active = QColorGroup( fg, btn, btn.light(150), btn.dark(),
btn.dark(150), fg, Qt::white, base, bg );
data->disabled = QColorGroup( disfg, btn, btn.light(150), btn.dark(),
btn.dark(150), disfg, Qt::white, base, bg );
data->inactive = data->active;
}
示例8: setBaseColor
void KZColorSelector::setBaseColor(const QColor& color) {
color.hsv(&baseColorH, &baseColorS, &baseColorV);
}
示例9: paintCell
//.........这里部分代码省略.........
p.setFont( font );
}
paintCache[column].map[colorKey] = buf;
}
else
p.drawPixmap( 0, 0, paintCache[column].map[colorKey] );
if( column == Rating )
drawRating( &p );
if( moodbarType == 1 )
drawMood( &p, width, height() );
}
else
{
const QColorGroup _cg = ( !exists() || !isEnabled() )
? listView()->palette().disabled()
: listView()->palette().active();
QColor bg = isSelected() ? _cg.highlight()
: isAlternate() ? listView()->alternateBackground()
: listView()->viewport()->backgroundColor();
#if KDE_IS_VERSION( 3, 3, 91 )
if( listView()->shadeSortColumn() && !isSelected() && listView()->columnSorted() == column )
{
/* from klistview.cpp
Copyright (C) 2000 Reginald Stadlbauer <[email protected]>
Copyright (C) 2000,2003 Charles Samuels <[email protected]>
Copyright (C) 2000 Peter Putzer */
if ( bg == Qt::black )
bg = QColor(55, 55, 55); // dark gray
else
{
int h,s,v;
bg.hsv(&h, &s, &v);
if ( v > 175 )
bg = bg.dark(104);
else
bg = bg.light(120);
}
}
#endif
const QColor textc = isSelected() ? _cg.highlightedText() : _cg.text();
buf.fill( bg );
// Draw column divider line
if( !isSelected() )
{
p.setPen( listView()->viewport()->colorGroup().mid() );
p.drawLine( width - 1, 0, width - 1, height() - 1 );
}
// Draw the pixmap, if present
int margin = listView()->itemMargin(), leftMargin = margin;
if ( pixmap( column ) ) {
p.drawPixmap( leftMargin, height() / 2 - pixmap( column )->height() / 2, *pixmap( column ) );
leftMargin += pixmap( column )->width();
}
if( align != Qt::AlignCenter )
align |= Qt::AlignVCenter;
if( column == Rating )
drawRating( &p );
else if( moodbarType == 1 )