{
maskPainter.setBrush(Qt::black);
maskPainter.setPen(Qt::black);
maskPainter.fillRect(-1,-1, mask.width()+1, mask.height()+1, Qt::white);
maskPainter.
setFont(QFont("Liberation Sans",
21,
QFont::Bold));
for (int i = 0; i < 16; i++)
{
text[i][0] = "X";
text[i][31] = "X";
}
for (int j = 0; j < 32; j++)
{
text[0][j] = "X";
text[15][j] = "X";
}
for (int i = 0; i < 16; i++)
{
for (int j = 0; j < 32; j++)
{
maskPainter.drawText(800*j/32,600*i/16,800/32,600/16, Qt::AlignBottom|Qt::AlignCenter, text[i][j]);
}
}
resize(mask.width(), mask.height());
clearMask();
setMask(mask);
}
void Widget::paintEvent(QPaintEvent *)
{
QPixmap mask;
mask = QPixmap(800, 600);
QString text[16][32];
QPainter maskPainter(&mask);
maskPainter.setBrush(Qt::black);
maskPainter.setPen(Qt::black);
maskPainter.fillRect(-1,-1, mask.width()+1, mask.height()+1, Qt::white);
maskPainter.setFont(QFont("Liberation Sans", 21, QFont::Bold));
for (int i = 0; i < 16; i++)
{
text[i][0] = "X";
text[i][31] = "X";
}
for (int j = 0; j < 32; j++)
{
text[0][j] = "X";
text[15][j] = "X";
}
for (int i = 0; i < 16; i++)
{
for (int j = 0; j < 32; j++)
{
maskPainter.drawText(800*j/32,600*i/16,800/32,600/16, Qt::AlignBottom|Qt::AlignCenter, text[i][j]);
}
}
resize(mask.width(), mask.height());
clearMask();
setMask(mask);
}
To copy to clipboard, switch view to plain text mode
Bookmarks