本文整理汇总了C++中QBrush::setTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ QBrush::setTexture方法的具体用法?C++ QBrush::setTexture怎么用?C++ QBrush::setTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBrush
的用法示例。
在下文中一共展示了QBrush::setTexture方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintEvent
void QGkhyMdiArea::paintEvent(QPaintEvent * paintEvent)
{
QBrush bk = background();
if (0 == m_bkPic || m_bkPic->size() != size())
{
m_bkPic.clear();
m_bkPic = QSharedPointer<QPixmap>(new QPixmap(size()));
QPainter painter(m_bkPic.data());
QImage img(":/Resources/gkhy_gray_banner.png");
QFont font("Verdana", 10);
painter.setFont(font);
// We will do something just as a doctor does in his O.R. when he
// gets a pot from a pig's face and then paints it onto a man's whole
// face.
painter.fillRect(m_bkPic->rect(), QColor(img.pixel(0, 0)));
painter.drawText(m_bkPic->rect(), Qt::AlignCenter,
"Beijing Transuniverse Space Technology Co., Ltd");
QRect imgSrcRect = img.rect();
QPoint offset = m_bkPic->rect().center() - imgSrcRect.center();
QRect imgDestRect = imgSrcRect.translated(offset);
painter.drawImage(imgDestRect, img);
}
bk.setTexture(*m_bkPic);
setBackground(bk);
QMdiArea::paintEvent(paintEvent);
}
示例2: pix
BoxWidget::BoxWidget(QWidget *parent, BasicBox *box)
: QWidget(parent)
{
_curveMap = new QMap<std::string, CurveWidget *>();
QBrush brush;
QPixmap pix(200, 70);
pix.fill(Qt::transparent);
brush.setTexture(pix);
QPalette palette;
palette.setColor(QPalette::Background, QColor(255, 0, 0, 127));
setPalette(palette);
setWindowFlags(Qt::Widget);
update();
_box = box;
_comboBox = new QComboBox;
_curveWidget = new CurveWidget(NULL);
_tabWidget = new QTabWidget;
_tabWidget->lower();
_tabWidget->setAttribute(Qt::WA_TranslucentBackground, true);
_stackedLayout = new QStackedLayout;
_stackedLayout->setStackingMode(QStackedLayout::StackAll);
_curvePageLayout = new QGridLayout;
setLayout(_stackedLayout);
_parentWidget = parent;
_curveWidgetList = new QList<CurveWidget *>;
_startMenu = NULL;
_endMenu = NULL;
}
示例3: readBrushNode
bool readBrushNode( const QDomElement& element, QBrush& brush )
{
bool ok = true;
QColor tempColor;
Qt::BrushStyle tempStyle = Qt::NoBrush;
QPixmap tempPixmap;
QDomNode node = element.firstChild();
while( !node.isNull() ) {
QDomElement element = node.toElement();
if( !element.isNull() ) { // was really an element
QString tagName = element.tagName();
if( tagName == "Color" ) {
ok = ok & readColorNode( element, tempColor );
} else if( tagName == "Style" ) {
QString value;
ok = ok & readStringNode( element, value );
tempStyle = stringToBrushStyle( value );
} else if( tagName == "Pixmap" ) {
ok = ok & readPixmapNode( element, tempPixmap );
} else {
qDebug( "Unknown tag in brush" );
}
}
node = node.nextSibling();
}
if( ok ) {
brush.setColor( tempColor );
brush.setStyle( tempStyle );
if( !tempPixmap.isNull() )
brush.setTexture( tempPixmap );
}
return ok;
}
示例4: QGraphicsView
TListPanel::TListPanel(QWidget* parent, Qt::WindowFlags)
: QGraphicsView(parent)
{
QPixmap *brushPixmap = new QPixmap("TListPanel/brush.png", "PNG");
QBrush *backgroundBrush = new QBrush();
backgroundBrush->setTexture(*brushPixmap);
this->setBackgroundBrush(*backgroundBrush);
this->setCacheMode(QGraphicsView::CacheBackground);
this->setAlignment(Qt::AlignLeft | Qt::AlignTop);
this->setVisible(true);
scene = new QGraphicsScene(this);
this->setScene(scene);
//infoText = new QGraphicsTextItem("");
this->currentIndex = 0;
countItems = 0;
x = 0;
y = 0;
h = 60;
otst = 10;
inc = 0;
listItems = new QList<frameStruct*>();
frameItems = new QList<TFrameItem*>();
}
示例5: drawLevelBase
void LevelBase::drawLevelBase(QPainter &painter)
{
rect = new QRect(0, floorStart, gameWindow, 40);
painter.drawRect(*rect);
QBrush brush;
brush.setTexture(*floor);
painter.fillRect(*rect, brush);
}//Draws the floor
示例6: setCircleDrawer
void LvlScene::setCircleDrawer()
{
if(cursor)
{delete cursor;
cursor=NULL;}
QPen pen;
QBrush brush;
switch(placingItem)
{
case PLC_Block:
case PLC_BGO:
default:
pen = QPen(Qt::gray, 2);
brush = QBrush(Qt::darkGray);
break;
}
//Align width and height to fit into item aligning
long addW=LvlPlacingItems::gridSz-LvlPlacingItems::itemW%LvlPlacingItems::gridSz;
long addH=LvlPlacingItems::gridSz-LvlPlacingItems::itemH%LvlPlacingItems::gridSz;
if(addW==LvlPlacingItems::gridSz) addW=0;
if(addH==LvlPlacingItems::gridSz) addH=0;
LvlPlacingItems::itemW = LvlPlacingItems::itemW+addW;
LvlPlacingItems::itemH = LvlPlacingItems::itemH+addH;
if((placingItem != PLC_Water) && (!LvlPlacingItems::sizableBlock))
{
QPixmap oneCell(LvlPlacingItems::itemW, LvlPlacingItems::itemH);
oneCell.fill(QColor(0xFF, 0xFF, 0x00, 128));
QPainter p(&oneCell);
p.setBrush(Qt::NoBrush);
p.setPen(QPen(Qt::yellow, 2, Qt::SolidLine));
p.drawRect(0,0, LvlPlacingItems::itemW, LvlPlacingItems::itemH);
brush.setTexture(oneCell);
}
cursor = addEllipse(0,0,1,1, pen, brush);
//set data flags
foreach(dataFlag flag, LvlPlacingItems::flags)
cursor->setData(flag.first, flag.second);
cursor->setData(ITEM_TYPE, "Circle");
cursor->setData(ITEM_IS_CURSOR, "CURSOR");
cursor->setZValue(7000);
cursor->setOpacity( 0.5 );
cursor->setVisible(false);
cursor->setEnabled(true);
SwitchEditingMode(MODE_DrawCircle);
DrawMode=true;
}
示例7: paintEvent
void MainWindow::paintEvent(QPaintEvent *){
auto map = QPixmap(QString(":/other/bg-chess.xcf"));//":/other/bg-chess.jpg"));
QPainter paint;
paint.begin(this);
QBrush brush;
brush.setTexture(map);
//brush.setStyle(Qt::RadialGradientPattern);
paint.setBrush(brush);//(QBrush (QColor (255, 255, 255, 200)));
paint.setPen (Qt::NoPen);
paint.drawRect (0, 0, width(), height());
paint.end();
}
示例8: QPixmap
QGraphicsRectItem *Board::CreateBoard()
{
QGraphicsRectItem *item = new QGraphicsRectItem;
QPixmap *pixmap = new QPixmap("D:\\programmieren\\RealChess\\ChessBoard.PNG");
QBrush *brush = new QBrush();
if(pixmap->isNull()) {
item->setBrush(Qt::green);
}
else {
brush->setTexture(*pixmap);
item->setBrush(*pixmap);
}
item->setRect(0,0,600,600);
return item;
}
示例9: background
QBrush DesktopBackgroundDialog::background()
{
QBrush background;
switch (m_type)
{
case (RazorWorkSpaceManager::BackgroundPixmap):
{
QPixmap pm(m_wallpaper);
pm = pm.scaled(m_desktopSize,
keepAspectCheckBox->isChecked() ? Qt::KeepAspectRatio : Qt::IgnoreAspectRatio,
Qt::SmoothTransformation);
background.setTexture(pm);
break;
}
default:
background.setColor(m_color);
background.setStyle(Qt::SolidPattern);
}
save();
return background;
}
示例10: QLabel
imageViewer::imageViewer(QWidget *parent): QLabel(parent)
{
addToLog("image creation",LOGIMAG);
validImage=false;
setFrameStyle(QFrame::Sunken | QFrame::Panel);
QBrush b;
QPalette palette;
b.setTexture(QPixmap::fromImage(QImage(":/icons/transparency.png")));
palette.setBrush(QPalette::Active,QPalette::Base,b);
palette.setBrush(QPalette::Inactive,QPalette::Base,b);
palette.setBrush(QPalette::Disabled,QPalette::Base,b);
setPalette(palette);
setBackgroundRole(QPalette::Base);
setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
setBackgroundRole(QPalette::Dark);
popup=new QMenu (this);
newAct = new QAction(tr("&New"),this);
connect(newAct, SIGNAL(triggered()), this, SLOT(slotNew()));
loadAct = new QAction(tr("&Load"), this);
connect(loadAct, SIGNAL(triggered()), this, SLOT(slotLoad()));
toTXAct = new QAction(tr("&To TX"), this);
connect(toTXAct, SIGNAL(triggered()), this, SLOT(slotToTX()));
editAct = new QAction(tr("&Edit"), this);
connect(editAct, SIGNAL(triggered()), this, SLOT(slotEdit()));
printAct = new QAction(tr("&Print"), this);
connect(printAct, SIGNAL(triggered()), this, SLOT(slotPrint()));
deleteAct = new QAction(tr("&Delete"), this);
connect(deleteAct, SIGNAL(triggered()), this, SLOT(slotDelete()));
viewAct = new QAction(tr("&View"), this);
connect(viewAct, SIGNAL(triggered()), this, SLOT(slotView()));
propertiesAct = new QAction(tr("Propert&ies"), this);
connect(propertiesAct, SIGNAL(triggered()), this, SLOT(slotProperties()));
connect(configDialogPtr,SIGNAL(bgColorChanged()), SLOT(slotBGColorChanged()));
init(RXIMG);
activeMovie=false;
//
}
示例11: paintEvent
void ThumbnailCanvas::paintEvent(QPaintEvent* event)
{
QWidget::paintEvent(event);
//paint grid
if (m_pixmap.isNull())
{
return;
}
QPainter painter(this);
QSize pixSize = m_pixmap.size();
QPoint topleft;
QBrush brush;
brush.setTexture(m_gridPixmap);
QPixmap scaledPix = m_pixmap.scaled(event->rect().size(), Qt::KeepAspectRatio);
if (event->rect().width() > event->rect().height())
{
topleft.setX((event->rect().width() - scaledPix.width()) / 2);
}
else
{
topleft.setY((event->rect().height() - scaledPix.height()) / 2);
}
painter.fillRect(topleft.x(), topleft.y(), scaledPix.width(), scaledPix.height(), brush);
if (needFitCanvas)
{
painter.drawPixmap(topleft, scaledPix);
}
else{
qDebug() << m_pixmap.size();
painter.drawPixmap(topleft, m_pixmap);
}
}
示例12: initializeBoard
void Board::initializeBoard()
{
/* WHITE CHIPS ---------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------*/
QPixmap *w_chipPixmapTower = new QPixmap("D:\\programmieren\\RealChess\\chip_w_t.JPG");
if(w_chipPixmapTower->isNull()) {
}
else {
QBrush *brush = new QBrush(*w_chipPixmapTower);
brush->setTexture(*w_chipPixmapTower);
//qDebug() <<"Chip: Brush Image Available"; //check if brush image is available
}
QPixmap *w_chipPixmapHorse = new QPixmap("D:\\programmieren\\RealChess\\chip_w_h.JPG");
if(w_chipPixmapHorse->isNull()) {
}
else {
QBrush *brush = new QBrush(*w_chipPixmapHorse);
brush->setTexture(*w_chipPixmapHorse);
//qDebug() <<"Chip: Brush Image Available"; //check if brush image is available
}
QPixmap *w_chipPixmapBishop = new QPixmap("D:\\programmieren\\RealChess\\chip_w_l.JPG");
if(w_chipPixmapBishop->isNull()) {
}
else {
QBrush *brush = new QBrush(*w_chipPixmapBishop);
brush->setTexture(*w_chipPixmapBishop);
//qDebug() <<"Chip: Brush Image Available"; //check if brush image is available
}
QPixmap *w_chipPixmapQueen = new QPixmap("D:\\programmieren\\RealChess\\chip_w_q.JPG");
if(w_chipPixmapQueen->isNull()) {
}
else {
QBrush *brush = new QBrush(*w_chipPixmapQueen);
brush->setTexture(*w_chipPixmapQueen);
//qDebug() <<"Chip: Brush Image Available"; //check if brush image is available
}
QPixmap *w_chipPixmapKing = new QPixmap("D:\\programmieren\\RealChess\\chip_w_k.JPG");
if(w_chipPixmapKing->isNull()) {
}
else {
QBrush *brush = new QBrush(*w_chipPixmapKing);
brush->setTexture(*w_chipPixmapKing);
//qDebug() <<"Chip: Brush Image Available"; //check if brush image is available
}
QPixmap *w_chipPixmapBauer = new QPixmap("D:\\programmieren\\RealChess\\chip_w_b.JPG");
if(w_chipPixmapBauer->isNull()) {
}
else {
QBrush *brush = new QBrush(*w_chipPixmapBauer);
brush->setTexture(*w_chipPixmapBauer);
//qDebug() <<"Chip: Brush Image Available"; //check if brush image is available
}
/* BLACK CHIPS -------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------*/
QPixmap *b_chipPixmapTower = new QPixmap("D:\\programmieren\\RealChess\\chip_b_t.JPG");
if(b_chipPixmapTower->isNull()) {
}
else {
QBrush *brush = new QBrush(*b_chipPixmapTower);
brush->setTexture(*b_chipPixmapTower);
//qDebug() <<"Chip: Brush Image Available"; //check if brush image is available
}
QPixmap *b_chipPixmapHorse = new QPixmap("D:\\programmieren\\RealChess\\chip_b_h.JPG");
if(b_chipPixmapHorse->isNull()) {
}
else {
QBrush *brush = new QBrush(*b_chipPixmapHorse);
brush->setTexture(*b_chipPixmapHorse);
//qDebug() <<"Chip: Brush Image Available"; //check if brush image is available
}
QPixmap *b_chipPixmapBishop = new QPixmap("D:\\programmieren\\RealChess\\chip_b_l.JPG");
if(b_chipPixmapBishop->isNull()) {
}
else {
QBrush *brush = new QBrush(*b_chipPixmapBishop);
brush->setTexture(*b_chipPixmapBishop);
//qDebug() <<"Chip: Brush Image Available"; //check if brush image is available
}
QPixmap *b_chipPixmapQueen = new QPixmap("D:\\programmieren\\RealChess\\chip_b_q.JPG");
if(b_chipPixmapQueen->isNull()) {
}
else {
QBrush *brush = new QBrush(*b_chipPixmapQueen);
brush->setTexture(*b_chipPixmapQueen);
//qDebug() <<"Chip: Brush Image Available"; //check if brush image is available
}
QPixmap *b_chipPixmapKing = new QPixmap("D:\\programmieren\\RealChess\\chip_b_k.JPG");
if(b_chipPixmapKing->isNull()) {
}
else {
//.........这里部分代码省略.........
示例13: setSectionBG
// ////////////////////////Apply section background/////////////////////////////
void LvlScene::setSectionBG(LevelSection section, bool forceTiled)
{
//QGraphicsPixmapItem * item=NULL;
QGraphicsRectItem * itemRect=NULL;
QBrush brush;
QPen pen;
QPixmap image = Themes::Image(Themes::dummy_bg);
QPixmap nullimage;
obj_BG *bgConfig=NULL;
QPixmap *img=NULL;
QPixmap *img2=NULL; //Second image buffer
//need a BGitem
bool noimage=false, wrong=false;
long x,y,h,w;
if(
(section.size_left!=0) ||
(section.size_top!=0)||
(section.size_bottom!=0)||
(section.size_right!=0)
)
{ //Don't draw on unallocated section entry
x=section.size_left;
y=section.size_top;
w=section.size_right;
h=section.size_bottom;
#ifdef _DEBUG_
WriteToLog(QtDebugMsg, "SetSectionBG-> Check for user images");
#endif
noimage=true;
if(section.background != 0 )
{
//Find user image
if(uBGs.contains(section.background))
{
noimage=false;
obj_BG &bgx = uBGs[section.background];
bgConfig=&bgx;
img =&bgx.image;
img2=&bgx.second_image;
} else //If not exist, will be used default
if(pConfigs->main_bg.contains(section.background))
{
noimage=false;
obj_BG &bgx = pConfigs->main_bg[section.background];
bgConfig=&bgx;
img =&bgx.image;
img2=&bgx.second_image;
}
if(noimage)
{
#ifdef _DEBUG_
WriteToLog(QtWarningMsg, "SetSectionBG-> Image not found");
#endif
img=ℑ
img2=&nullimage;
wrong=true;
}
}
else noimage=true;
brush = QBrush(QColor(0, 0, 0));
pen = QPen(Qt::NoPen);
if((!noimage)&&(!img->isNull()))
{
DrawBG(x, y, w, h, section.id, *img, *img2, *bgConfig, forceTiled);
}
else
{
if(wrong)
brush.setTexture(image);
itemRect = new QGraphicsRectItem;
itemRect->setPen(pen);
itemRect->setBrush(brush);
itemRect->setRect(x, y, labs(x-w), labs(y-h));
addItem(itemRect);
}
#ifdef _DEBUG_
WriteToLog(QtDebugMsg, QString("SetSectionBG-> Item placed to x=%1 y=%2 h=%3 w=%4").arg(x).arg(y)
.arg((long)fabs(x-w)).arg((long)fabs(y-h)));
#endif
//
if(itemRect!=NULL)
{
itemRect->setData(ITEM_TYPE, QString("BackGround%1").arg(section.id) );
itemRect->setZValue(Z_backImage);
}
} //Don't draw on reserved section entry
}
示例14: setSectionBG
// ////////////////////////Apply section background/////////////////////////////
void LvlScene::setSectionBG(LevelSection section, bool forceTiled)
{
//QGraphicsPixmapItem * item=NULL;
QGraphicsRectItem * itemRect=NULL;
QBrush brush;
QPen pen;
QPixmap image = Themes::Image(Themes::dummy_bg);
QPixmap img;
QPixmap img2; //Second image buffer
//need a BGitem
bool isUser1=false, isUser2=false, noimage=false, wrong=false;
long x,y,h,w, j;
if(
(section.size_left!=0) ||
(section.size_top!=0)||
(section.size_bottom!=0)||
(section.size_right!=0)
)
{ //Don't draw on unallocated section entry
x=section.size_left;
y=section.size_top;
w=section.size_right;
h=section.size_bottom;
#ifdef _DEBUG_
WriteToLog(QtDebugMsg, "SetSectionBG-> Check for user images");
#endif
isUser1=false; // user's images are exist
isUser2=false; // user's images are exist
noimage=true;
j = 0;
if(section.background != 0 )
{
//Find user image
for(j=0;j<uBGs.size();j++)
{
if(uBGs[j].id==section.background)
{
noimage=false;
if((uBGs[j].q==0)||(uBGs[j].q==2)) //set first image
{img = uBGs[j].image; isUser1=true;}
if((uBGs[j].q>=1)){ // set Second image
img2 = uBGs[j].second_image; isUser2=true;}
break;
}
} //If not exist, will be used default
j=pConfigs->getBgI(section.background);
if(j>=0)
{
noimage=false;
if(!isUser1)
img = pConfigs->main_bg[j].image;
if(!isUser2)
img2 = pConfigs->main_bg[j].second_image;
}
if((noimage)&&(!isUser1))
{
#ifdef _DEBUG_
WriteToLog(QtWarningMsg, "SetSectionBG-> Image not found");
#endif
img=image;
wrong=true;
}
}
else noimage=true;
//pConfigs->main_bg[j].type;
brush = QBrush(QColor(0, 0, 0));
//QBrush brush(QColor(255, 255, 255));
pen = QPen(Qt::NoPen);
//for (int i = 0; i < 11; i++) {
//item = addRect(QRectF(x, y, , ), pen, brush);
if((!noimage)&&(!img.isNull()))
{
//item = addPixmap(image);
//item = new QGraphicsPixmapItem;
DrawBG(x, y, w, h, section.id, img, img2, pConfigs->main_bg[j], forceTiled);
//BgItem[section.id]->setParentItem(item);
//addItem(item);
//item->setData(ITEM_TYPE, "BackGround"+QString::number(section.id) );
//item->setPos(x, y);
}
else
{
if(wrong)
brush.setTexture(image);
itemRect = new QGraphicsRectItem;
itemRect->setPen(pen);
itemRect->setBrush(brush);
itemRect->setRect(x, y, (long)fabs(x-w), (long)fabs(y-h));
addItem(itemRect);
//.........这里部分代码省略.........