本文整理汇总了C++中QBrush::setTextureImage方法的典型用法代码示例。如果您正苦于以下问题:C++ QBrush::setTextureImage方法的具体用法?C++ QBrush::setTextureImage怎么用?C++ QBrush::setTextureImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBrush
的用法示例。
在下文中一共展示了QBrush::setTextureImage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintEvent
//-----------------------------------------------------------------------------
//! Use a dark ribbed textured background
//-----------------------------------------------------------------------------
void tQuickInfoPanel::paintEvent( QPaintEvent* pEvent )
{
QImage image( 1, 4, QImage::Format_RGB32 );
image.setPixel( 0, 0, QColor( 49, 59, 64 ).rgb() );
image.setPixel( 0, 1, QColor( 49, 59, 64 ).rgb() );
image.setPixel( 0, 2, QColor( 39, 46, 51 ).rgb() );
image.setPixel( 0, 3, QColor( 39, 46, 51 ).rgb() );
QBrush brush;
brush.setTextureImage( image );
QPainter painter( this );
painter.fillRect( pEvent->rect(), brush );
}
示例2: addNewRow
void TargetList::addNewRow(QString fileName, QString name, QString coordinates, QString description)
{
// Creates image preview item
QTableWidgetItem *image = new QTableWidgetItem();
QBrush brush;
QImage brushImage;
if (fileName == "")
brushImage.load(defaultImagePath);
else
brushImage.load(fileName);
// Resize image -> Make this dependent on row/col size
int width = 150;
int height = 100;
QImage scaledBrushImage = brushImage.scaled(width, height, Qt::KeepAspectRatio);
image->setData(Qt::DecorationRole, QPixmap(fileName).scaled(150, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation));
image->setTextAlignment(Qt::AlignHCenter);
// Apply resized image
brush.setTextureImage(scaledBrushImage);
//image->setImage(brush);
// Creates name item
QFont font("Segoe UI", 11, QFont::Bold);
QTableWidgetItem *nameItem = new QTableWidgetItem();
nameItem->setText(name);
nameItem->setFont(font);
// Creates coordinate item
QTableWidgetItem *coordItem = new QTableWidgetItem();
coordItem->setText(coordinates);
// Creates description item
QTableWidgetItem *descItem = new QTableWidgetItem();
descItem->setText(description);
// Places item in a TargetListItem and adds it to the target list
TargetListItem *newItem = new TargetListItem(image, nameItem, coordItem, descItem);
newItem->imageFilePath = fileName;
rows->prepend(newItem);
refreshTable();
}
示例3: addNewRow
void TargetList::addNewRow(QString fileName, QString name, QString coordinates, QString description, int x, int y, bool refresh)
{
// Creates image preview item
QTableWidgetItem *image = new QTableWidgetItem();
QBrush brush;
QImage brushImage;
if (fileName == "")
brushImage.load(defaultImagePath);
else
brushImage.load(fileName);
// Resize image
int width = 100;
int height = 100;
QImage scaledBrushImage = brushImage.scaled(width, height, Qt::IgnoreAspectRatio);
// Apply resized image
brush.setTextureImage(scaledBrushImage);
image->setBackground(brush);
// Creates name item
QFont font("Segoe UI", 11, QFont::Bold);
QTableWidgetItem *nameItem = new QTableWidgetItem();
nameItem->setText(name);
nameItem->setFont(font);
// Creates coordinate item
QTableWidgetItem *coordItem = new QTableWidgetItem();
coordItem->setText(coordinates);
// Creates description item
QTableWidgetItem *descItem = new QTableWidgetItem();
descItem->setText(description);
// Places item in a TargetListItem and adds it to the target list
TargetListItem *newItem = new TargetListItem(image, nameItem, coordItem, descItem, x, y);
newItem->imageFilePath = fileName;
rows->append(newItem);
if (refresh)
refreshTable();
}
示例4: drawBrush
QImage BrushPainter::drawBrush(Brush &brush, QSize size)
{
QImage img(size, QImage::Format_RGBA8888);
QGraphicsColorizeEffect *effect;
QGraphicsBlurEffect *blur;
effect = new QGraphicsColorizeEffect();
blur = new QGraphicsBlurEffect();
effect->setColor(brush.color_main);
blur->setBlurRadius(brush.blur);
QImage drawImg = applyEffectToImage(brush.img,effect);
int width = drawImg.scaled(brush.size, brush.size, Qt::KeepAspectRatio).width();
if(width < 4)
width = 4;
QBrush qBrush;
QPainter paint(&img);
paint.setBrush(qBrush);
QImage resultImg;
QTransform transformation;
paint.setOpacity((double)brush.opacity/100);
int n = (size.width() - 100 ) / (width/4);
n--;
for(int j = 0; j <= brush.count; j++)
for(int i = 0; i < n; i++)
{
int b = brush.size_delta/2 - rand() % ((int)brush.size_delta + 1);
int m = brush.dispers/2 - rand() % ((int)brush.dispers + 1);
// transformation.rotate(brush.angle_delta/2 - rand() % ((int)brush.angle_delta + 1));
resultImg = drawImg.scaled(brush.size + b, brush.size + b, Qt::KeepAspectRatio).transformed(transformation);
qBrush.setTextureImage(resultImg);
paint.drawImage(i*resultImg.width()/4,size.height()/2 - resultImg.height()/2 + m,resultImg);
}
// paint.fillRect(0,0,200,200,QBrush(brush.color_main, Qt::SolidPattern));
bool bEnd = paint.end();
return applyEffectToImage(img, blur);
}
示例5: editRow
void TargetList::editRow(int row, QString fileName, QString name, QString coordinates, QString description)
{
// Creates image preview item
QBrush brush;
QImage brushImage;
if (fileName == "")
brushImage.load(defaultImagePath);
else
brushImage.load(fileName);
// Resize image
int width = 150;
int height = 100;
QImage scaledBrushImage = brushImage.scaled(width, height, Qt::IgnoreAspectRatio);
// Apply resized image
brush.setTextureImage(scaledBrushImage);
rows->at(row)->image->setBackground(brush);
rows->at(row)->name->setText(name);
rows->at(row)->coord->setText(coordinates);
rows->at(row)->desc->setText(description);
refreshTable();
}
示例6: paintEvent
void mainWidget::paintEvent(QPaintEvent *)
{
QBitmap bitmap(this->size());
bitmap.fill();
QPainter painter(&bitmap);
painter.setBrush(QBrush(Qt::black));
painter.drawRoundedRect(bitmap.rect(),5,5);
setMask(bitmap);
QPixmap pixmap(this->size());
pixmap.fill();
painter.end();
painter.begin(&pixmap);
painter.setRenderHints(QPainter::Antialiasing,true);
QBrush brush;
brush.setStyle(Qt::TexturePattern);
brush.setTextureImage(QImage(bkPicName));
painter.setBrush(brush);
painter.setPen(Qt::black);
painter.drawRoundedRect(rect(),5,5);
painter.end();
painter.begin(this);
painter.drawPixmap(this->rect(),pixmap);
}
示例7: paintEvent
void ColorGridView::paintEvent(QPaintEvent *event)
{
// To make it clear, we do not use delegate at all
// QItemSelectionModel *selections = selectionModel();
QStyleOptionViewItem option = viewOptions();
QStyle::State state = option.state;
QBrush background = option.palette.base();
QPen foreground(option.palette.color(QPalette::WindowText));
QPen textPen(option.palette.color(QPalette::Text));
QPen highlightedPen(option.palette.color(QPalette::HighlightedText));
QPainter painter(viewport());
// close anti aliasing to make it more clear
// painter.setRenderHint(QPainter::Antialiasing);
painter.fillRect(event->rect(), background);
painter.setPen(Qt::white);
QBrush brush;
brush.setTextureImage(backgroundImg);
painter.setBrush(brush);
painter.translate(margin - horizontalScrollBar()->value(),
margin - verticalScrollBar()->value());
for(int i = 0; i<gridCount; ++i){
for(int j=0; j<gridCount; ++j){
painter.drawImage(i*(gridMargin+gridWidth),j*(gridMargin+gridWidth),
backgroundImg);
}
}
if( !model() )return;
for (int row = 0; row < model()->rowCount(rootIndex()); ++row) {
for(int column = 0; column < model()->columnCount(rootIndex()); ++column)
{
QModelIndex index = model()->index(row, column, rootIndex());
QColor color = model()->data(index).value<QColor>();
int j = index.row();
int i = index.column();
if(color.isValid()){
//draw white background to prevent disturbings of background if transparent color
painter.setBrush(Qt::white);
painter.drawRect(i*(gridMargin+gridWidth),j*(gridMargin+gridWidth),
gridWidth,gridWidth);
painter.setBrush(color);
painter.drawRect(i*(gridMargin+gridWidth),j*(gridMargin+gridWidth),
gridWidth,gridWidth);
}
}
}
QModelIndexList list = selectedIndexes();
if( !list.isEmpty() ){
QModelIndex index = list.at(0);
// Qt::ItemFlags flags = index.flags();
// if(flags.testFlag(QItemSelectionModel::Select)){
painter.setPen(textPen);
// }
// if(flags.testFlag(QItemSelectionModel::Toggle)){
// painter.setPen(highlightedPen);
// }
int row = index.row();
int column = index.column();
// QPointF start(column*(gridMargin+gridWidth),row*(gridMargin+gridWidth));
// QRadialGradient gradient(start+QPointF(gridWidth/2,gridWidth/2),0.1,start+QPointF(gridWidth,gridWidth));
// gradient.setColorAt(0.5,Qt::transparent);
// gradient.setColorAt(1.0,Qt::black);
// foreground = QPen(Qt::black);
// QBrush brush(gradient);
// brush.setStyle(Qt::RadialGradientPattern);
painter.setBrush(Qt::NoBrush);
// painter.setBrush(brush);
painter.drawRect(column*(gridMargin+gridWidth),row*(gridMargin+gridWidth),
gridWidth,gridWidth);
}
}