16,215
社区成员
发帖
与我相关
我的任务
分享
void ChessMan::paintEvent(QPaintEvent *)
{
QPainter painter(this);
qDebug() << "abc";
if(this->killed != 1)
{
if(selected == 1){
this->pixmap.load("./images/selected.png");
painter.drawPixmap(this->position.rx()*60+30,
this->position.ry()*60+30,50,50,pixmap);
}
this->pixmap.load(QString("./images/")+ picNames[this->type - 1]);
painter.drawPixmap(this->position.rx()*60+30,
this->position.ry()*60+30,50,50,pixmap);
}
}
ChessGame::ChessGame(QWidget *parent) :
QWidget(parent)
{
this->setGeometry(0,0,600,652);
this->setAutoFillBackground(true);
QPixmap pixmap("./images/chessBoard.png");
QPalette palette;
palette.setBrush(QPalette::Background, QBrush(pixmap));
this->setPalette(palette);
initChessBoard();
QPoint pos;
for(int i = 0,k = 0;i < 10;i++)
for(int j = 0;j < 9;j++)
{
if(chessBoard[i][j] != NOCHESS)
{
pos.setX(j);
pos.setY(i);
chessMan[k] = new ChessMan(chessBoard[i][j],pos,k,0,0,this);
chessMan[k++]->show();
// chessMan[k++]->repaint();
qDebug() << chessMan[k-1]->type;
}
}
}