Search code examples
c++qtqpainterpaintevent

Qt - creating QPainter


I'm trying to rewrite method paintEvent in my programm and change it.

void MainWindow::paintEvent(QPaintEvent *event)
{
    QRegion reg = this->bgPixmapHandle->rect();
    QPainter painter(this);

    painter.setClipRegion(reg);
    painter.drawImage(bgPixmapHandle->rect(), bgPixmapHandle);
    painter.end();
}

Here I try to change my bg image. But I got an error on line: QPainter painter(this);

Error: Variable 'QPainter painter' is initialized, though the type is incomplete


Solution

  • Include QPainter header file. QPainter class is only forward declared in one of the Qt headers you're including in that translation unit.