Question

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

Was it helpful?

Solution

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

OTHER TIPS

#include <QPainter>

Are you including ? Qt is a big fan of forward declaration of classes, which causes such cryptic errors.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top