Max Frai
Max Frai

Reputation: 64266

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

Upvotes: 0

Views: 2499

Answers (3)

Ariya Hidayat
Ariya Hidayat

Reputation: 12561

#include <QPainter>

Upvotes: 2

Cătălin Pitiș
Cătălin Pitiș

Reputation: 14341

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

Upvotes: 7

Ben Hughes
Ben Hughes

Reputation: 14185

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

Upvotes: 1

Related Questions