views:

334

answers:

3

Hello, 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

C++ and Qt.

A: 

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

Ben Hughes
+5  A: 

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

Cătălin Pitiș
+1  A: 
#include <QPainter>
Ariya Hidayat