Hi!
I have my own subclass of QGraphicsView which displays a QGraphicsScene. I add lines on the scene. Now I also want do add QImages to the scene (or view).
I have tried the following:
I overode QWidget:: paintEvent(QPaintEvent*) in my QGraphicsView subclass:
painter.begin(this);
QPointF point
(GetCenter
().
x(), GetCenter
().
y());
painter.drawImage(point, *image);
painter.end();
}
void myViewSubclass:paintEvent(QPaintEvent * event) {
QGraphicsView::paintEvent(event);
QPainter painter;
painter.begin(this);
QPointF point(GetCenter().x(), GetCenter().y());
painter.drawImage(point, *image);
painter.end();
}
To copy to clipboard, switch view to plain text mode
Unfortunately Qt Creator tells me:
QPainter::begin: Widget painting can only begin as a result of a paintEvent
But I only paint in the above method which IS the result of a paint Event...
Where is my mistake? Or is my aprroach to drawing an image on the scene rubbish anyway?
Bookmarks