QPainter not active
21,322
The problem was that, as Colin pointed out, pix
was size zero.
Author by
wrongusername
Updated on July 09, 2022Comments
-
wrongusername almost 2 years
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?