Собсна, код:
#include <QMainWindow>
#include <QScrollArea>
#include <QLabel>
#include <QApplication>
#include <QPainter>
class MyLabel : public QLabel {
protected:
virtual void paintEvent(QPaintEvent* e) {
QLabel::paintEvent(e);
QPainter p(this);
p.setPen(Qt::green);
p.drawLine(0, 0, 100, 100);
}
};
class ImageView : public QMainWindow {
public:
ImageView() : QMainWindow() {
QScrollArea* scr = new QScrollArea();
setCentralWidget( scr );
QLabel* label = new MyLabel();
label->setPixmap(QPixmap("./moon_from_andrey.jpg"));
scr->setWidget(label);
}
};
int main(int argc, char* argv[]) {
QApplication app(argc, argv);
ImageView view;
view.setGeometry(100, 100, 500, 400);
view.show();
return app.exec();
}
Результат: