本文整理汇总了C++中QColorGroup::background方法的典型用法代码示例。如果您正苦于以下问题:C++ QColorGroup::background方法的具体用法?C++ QColorGroup::background怎么用?C++ QColorGroup::background使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QColorGroup
的用法示例。
在下文中一共展示了QColorGroup::background方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawComplexControl
/*!\reimp
*/
void QPlatinumStyle::drawComplexControl( ComplexControl control,
QPainter *p,
const QWidget *widget,
const QRect &r,
const QColorGroup &cg,
SFlags how,
SCFlags sub,
SCFlags subActive,
const QStyleOption& opt ) const
{
switch ( control ) {
case CC_ComboBox:
{
int x,
y,
w,
h;
r.rect( &x, &y, &w, &h );
p->fillRect( x + 2, y + 2, w - 4,
h - 4, cg.brush(QColorGroup::Button) );
// the bright side
p->setPen(cg.shadow());
p->drawLine( x, y, x + w - 1, y );
p->drawLine( x, y, x, y + h - 1 );
p->setPen( cg.light() );
p->drawLine( x + 1, y + 1,
x + w - 2, y + 1 );
p->drawLine( x + 1, y + 1,
x + 1, y + h - 2 );
// the dark side!
p->setPen( cg.mid() );
p->drawLine( x + 2, y + h - 2,
x + w - 2, y + h - 2 );
p->drawLine( x + w - 2, y + 2,
x + w - 2, y + h - 2 );
p->setPen (cg.shadow() );
p->drawLine( x + 1, y + h - 1,
x + w - 1, y + h - 1 );
p->drawLine( x + w - 1, y,
x + w - 1, y + h - 1 );
// top left corner:
p->setPen( cg.background() );
p->drawPoint( x, y );
p->drawPoint( x + 1, y );
p->drawPoint( x, y + 1 );
p->setPen( cg.shadow() );
p->drawPoint( x + 1, y + 1 );
p->setPen( white );
p->drawPoint( x + 3, y + 3 );
// bottom left corner:
p->setPen( cg.background() );
p->drawPoint( x, y + h - 1 );
p->drawPoint( x + 1, y + h - 1 );
p->drawPoint( x, y + h - 2 );
p->setPen( cg.shadow() );
p->drawPoint( x + 1, y + h - 2 );
// top right corner:
p->setPen( cg.background() );
p->drawPoint( x + w - 1, y );
p->drawPoint( x + w - 2, y );
p->drawPoint( x + w - 1, y + 1 );
p->setPen( cg.shadow() );
p->drawPoint( x + w - 2, y + 1 );
// bottom right corner:
p->setPen( cg.background() );
p->drawPoint( x + w - 1, y + h - 1 );
p->drawPoint( x + w - 2, y + h - 1 );
p->drawPoint( x + w - 1, y + h - 2 );
p->setPen( cg.shadow() );
p->drawPoint( x + w - 2, y + h - 2 );
p->setPen( cg.dark() );
p->drawPoint( x + w - 3, y + h - 3 );
if ( sub & SC_ComboBoxArrow ) {
QRect rTmp = querySubControlMetrics( CC_ComboBox, widget,
SC_ComboBoxArrow, opt );
int xx = rTmp.x(),
yy = rTmp.y(),
ww = rTmp.width(),
hh = rTmp.height();
// the bright side
p->setPen( cg.mid() );
p->drawLine( xx, yy+2, xx, yy+hh-3 );
p->setPen( cg.button() );
p->drawLine( xx+1, yy+1, xx+ww-2, yy+1 );
p->drawLine( xx+1, yy+1, xx+1, yy+hh-2 );
p->setPen( cg.light() );
p->drawLine( xx+2, yy+2, xx+2, yy+hh-2 );
p->drawLine( xx+2, yy+2, xx+ww-2, yy+2 );
//.........这里部分代码省略.........
示例2: paintCell
void DataViewTable::paintCell(QPainter* painter, int row, int col,
const QRect& cr, bool selected, const QColorGroup& cg) {
if (selector_ == NULL || row < 0 || col < 0)
return;
QRect rect(0, 0, cr.width(), cr.height());
if (selected) {
painter->fillRect(rect, cg.highlight());
painter->setPen(cg.highlightedText());
} else {
if (row % 2) {
painter->fillRect(rect, cg.base());
} else {
painter->fillRect(rect, cg.background().light(135));
}
painter->setPen(cg.text());
}
const SelectList &flist = selector_->pickList();
// Check for row out of bounds.
int max_row_id = flist.size() - 1;
if (row > max_row_id)
return;
// determine if table has optional col for the feature id
bool show_id = Preferences::getConfig().dataViewShowFID;
if (show_id && col == 0) {
painter->drawText(rect, Qt::AlignRight, QString::number(flist[row]));
return;
}
if (!selector_->HasAttrib()) {
// we don't have anny attribs, bail now
return;
}
// we don't have to worry about fails attribute fetches since we are anly
// asking for records that are already in our select list and they cannot
// get into the select list w/o a valid record.
gstRecordHandle rec;
try {
rec = theSourceManager->GetAttributeOrThrow(
UniqueFeatureId(selector_->getSourceID(), selector_->layer(),
flist[row]));
} catch (...) {
// silently ignore. see comment before 'try'
return;
}
int num_fields = static_cast<int>(rec->NumFields());
// Check for column out of bounds.
int max_column_id = show_id ? num_fields : num_fields - 1;
if (col > max_column_id)
return;
gstValue* val = rec->Field(show_id ? col - 1 : col);
int tf = val->IsNumber() ? Qt::AlignRight : Qt::AlignLeft;
int rowHeight = this->rowHeight(row);
int colWidth = this->columnWidth(col);
QRect bounding_rect = fontMetrics().boundingRect(val->ValueAsUnicode());
// fontMetrics should account for the font descenders, but it
// seems to be broken.
// I accounted for the descenders by adding a margin of 4 around the cell
// contents to account for errors in the fontMetrics
// height estimation for font descenders, e.g., the tail of
// the "y" or "p") . This seems to work for even large fonts and
// is readable for smaller fonts.
int added_cell_margin = 4;
int cellWidth = bounding_rect.width() + added_cell_margin * 2;
int cellHeight = bounding_rect.height() + added_cell_margin * 2;
if (cellHeight > rowHeight) {
setRowHeight(row, cellHeight);
}
if (cellWidth > colWidth) {
setColumnWidth(col, cellWidth);
}
// When drawing, we're going to force the horizontal margin here.
QRect text_rect(added_cell_margin, 0, cr.width() - added_cell_margin, cr.height());
painter->drawText(text_rect, tf, val->ValueAsUnicode());
}
示例3: drawPrimitive
//.........这里部分代码省略.........
if ( !(flags & (Style_Down | Style_On)) ) {
p->fillRect( x+3, y+3, w-6, h-6,
cg.brush( QColorGroup::Button ));
// the bright side
p->setPen( cg.shadow() );
p->drawLine( x, y, x+w-1, y );
p->drawLine( x, y, x, y + h - 1 );
p->setPen( cg.button() );
p->drawLine( x + 1, y + 1, x + w - 2, y + 1 );
p->drawLine( x + 1, y + 1, x + 1, y + h - 2 );
p->setPen( cg.light() );
p->drawLine( x + 2, y + 2, x + 2, y + h - 2 );
p->drawLine( x + 2, y + 2, x + w - 2, y + 2 );
// the dark side!
p->setPen( cg.mid() );
p->drawLine( x + 3, y + h - 3 ,x + w - 3, y + h - 3 );
p->drawLine( x + w - 3, y + 3, x + w - 3, y + h - 3 );
p->setPen( cg.dark() );
p->drawLine( x + 2, y + h - 2, x + w - 2, y + h - 2 );
p->drawLine( x + w - 2, y + 2, x + w - 2, y + h - 2 );
p->setPen( cg.shadow() );
p->drawLine( x + 1, y + h - 1, x + w - 1, y + h - 1 );
p->drawLine( x + w - 1, y, x + w - 1, y + h - 1 );
// top left corner:
p->setPen( cg.background() );
p->drawPoint( x, y );
p->drawPoint( x + 1, y );
p->drawPoint( x, y+1 );
p->setPen( cg.shadow() );
p->drawPoint( x + 1, y + 1 );
p->setPen( cg.button() );
p->drawPoint( x + 2, y + 2 );
p->setPen( white );
p->drawPoint( x + 3, y + 3 );
// bottom left corner:
p->setPen( cg.background() );
p->drawPoint( x, y + h - 1 );
p->drawPoint( x + 1, y + h - 1 );
p->drawPoint( x, y + h - 2 );
p->setPen( cg.shadow() );
p->drawPoint( x + 1, y + h - 2 );
p->setPen( cg.dark() );
p->drawPoint( x + 2, y + h - 3 );
// top right corner:
p->setPen( cg.background() );
p->drawPoint( x + w -1, y );
p->drawPoint( x + w - 2, y );
p->drawPoint( x + w - 1, y + 1 );
p->setPen( cg.shadow() );
p->drawPoint( x + w - 2, y + 1 );
p->setPen( cg.dark() );
p->drawPoint( x + w - 3, y + 2 );
// bottom right corner:
p->setPen( cg.background() );
p->drawPoint( x + w - 1, y + h - 1 );
p->drawPoint( x + w - 2, y + h - 1 );
p->drawPoint( x + w - 1, y + h - 2 );
示例4: drawSegment
//.........这里部分代码省略.........
if (erase)
p.setPen(g.light());
break;
case 2 :
pt.rx() += (QCOORD)(Segment_Length);
if (erase)
p.setPen(offcolor);
pts.setPoints(3,pt.x() , pt.y() ,
pt.x() , pt.y() - Width + 1, // changes from 1 to 2
pt.x() - Width +1, pt.y() );
p.drawPolygon(pts);
pts.setPoints(3,pt.x() , pt.y() + Segment_Length - Width - Width/2 -1,
pt.x() , pt.y() + Segment_Length - 3*Width/4 - 1,
pt.x() - Width +1, pt.y() + Segment_Length - Width - Width/2 -1);
p.drawPolygon(pts);
if (erase)
p.setPen(g.light());
p.fillRect(pt.x() - Width+1 ,pt.y() + Width/2- 1, Width ,
Segment_Length - Width - Width + 1 ,brush);
break;
case 3 :
pt.ry() += (QCOORD)Segment_Length;
p.setPen(g.background());
pts.setPoints(3,pt.x()-1 , pt.y() - Width/2 -1,
pt.x() + Width+2, pt.y()-Width -1 ,//
pt.x() + Width+2, pt.y() );
p.drawPolygon(pts);
pts.setPoints(3,pt.x() + Segment_Length + 1, pt.y() - Width/2 -1 ,
pt.x() + Segment_Length - Width - 2 ,
pt.y() - Width -1,
pt.x() + Segment_Length - Width - 2, pt.y() );
p.drawPolygon(pts);
p.setPen(g.light());
p.fillRect(pt.x() + Width -1 ,pt.y() - Width, Segment_Length- 2* Width + 3,
Width ,brush);
break;
case 4 :
pt.ry() += (QCOORD)(Segment_Length +1);
p.fillRect(pt.x(), pt.y(), Width , Segment_Length - Width - Width/2 ,brush);
if (erase)
p.setPen(offcolor);
pts.setPoints(3,pt.x(), pt.y(),
pt.x(), pt.y()-Width+1,
pt.x() + Width-1, pt.y());
p.drawPolygon(pts);
pts.setPoints(3,pt.x(), pt.y() + Segment_Length -Width - Width/2 -1 ,
pt.x() + Width -1 , pt.y() -Width +Segment_Length - Width/2 -1 ,
pt.x() , pt.y() + Segment_Length - 3*Width/4 -1);
p.drawPolygon(pts);
if (erase)