The following code results in a bunch of errors:
void MainWindow::displayBoard()
{
QPixmap pix(0,0);
pix.fill(Qt::white);
QPainter painter(&pix);
painter.setBrush(Qt::black);
for(int row = 0; row < 8; row++)
for(int col = 0; col < 8; col++)
painter.drawRect(row * 10, col * 10, 10, 10);
ui->label->setPixmap(pix);
}
The errors:
QPainter::begin: Paint device returned engine == 0, type: 2
QPainter::setBrush: Painter not active
QPainter::drawRects: Painter not active
How can I resolve this error?
The problem was that, as Colin pointed out, pix
was size zero.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With