本文整理汇总了C++中Stone::setPixmap方法的典型用法代码示例。如果您正苦于以下问题:C++ Stone::setPixmap方法的具体用法?C++ Stone::setPixmap怎么用?C++ Stone::setPixmap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stone
的用法示例。
在下文中一共展示了Stone::setPixmap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawStones
void BoardView::drawStones()
{
static QPixmap* bstone = new QPixmap(":/images/blackstone.gif");
static QPixmap* wstone = new QPixmap(":/images/wwstone.gif");
if (this->_board != 0)
{
Coord* lastCoord = 0;
QBrush lastBrush;
for (unsigned int i = 0; i < this->_board->getSize(); i++)
{
for (unsigned int j = 0; j < this->_board->getSize(); j++)
{
QBrush brush;
if (BoardCell::matchMask(*this->_board->getCell(i, j), WHITE))
brush = QBrush(Qt::white);
else if (BoardCell::matchMask(*this->_board->getCell(i, j), BLACK))
brush = QBrush(Qt::black);
if (!BoardCell::isEmpty(*this->_board->getCell(i, j)))
{
Coord c = this->getCoord(i, j);
if (this->_board->getLastPlayed())
{
Coord lastCell = this->getCoord(this->_board->getLastPlayed()->x, this->_board->getLastPlayed()->y);
if (c.x == lastCell.x && c.y == lastCell.y)
{
lastCoord = new Coord(c.x, c.y);
lastBrush = brush;
}
}
if (!lastCoord || lastCoord->x != c.x || lastCoord->y != c.y)
{
QGraphicsPixmapItem* item;
double width;
if (brush.color() == Qt::black)
{
item = this->_scene.addPixmap(*bstone);
width = bstone->width();
}
else
{
item = this->_scene.addPixmap(*wstone);
width = wstone->width();
}
item->setPos(c.x, c.y);
item->setScale(this->_lineSpacing/width);
}
}
}
}
if (lastCoord)
{
Stone* stone = new Stone();
double width;
if (lastBrush.color() == Qt::black)
{
stone->setPixmap(*bstone);
width = bstone->width();
}
else
{
stone->setPixmap(*wstone);
width = wstone->width();
}
stone->initScaleAndOffset(lastCoord->x, lastCoord->y,
this->_lineSpacing/width, this->_lineSpacing/2);
this->_scene.addItem(stone);
QPropertyAnimation* animation = new QPropertyAnimation(stone, "scale");
animation->setDuration(200);
animation->setStartValue(0.0);
animation->setEndValue(this->_lineSpacing/width);
animation->setEasingCurve(QEasingCurve::OutBounce);
animation->start();
delete lastCoord;
}
}
else
std::cout << "drawStones(): Warning: No board set in BoardView" << std::endl;
}