I am learning QT and I am puzzled by the difference in performance of QLabel and QGraphics view while panning.
I read a huge 36Mpixels (D800) jpeg file into either QLabel or QGraphics objects and try to drag the full scale image with QLabel/Graphics. Surprisingly, the QLabel provides really smooth movement while QGRaphicsView panning is jerky.
The simplified QGraphicsView code is:
QApplication::setGraphicsSystem("raster");
...
QGraphicsView view();
view.setDragMode(QGraphicsView::ScrollHandDrag);
view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view.setFrameStyle(QFrame::NoFrame);
view.showFullScreen();
QGraphicsPixmapItem *pmItem = new QGraphicsPixmapItem(pixMap);
scene.addItem(pmItem); // only one item in the scene
//view.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); // no difference
view.show();
The simplified QLabel based code is:
void MyQLabel::mouseMoveEvent(QMouseEvent *event){
if(_leftButtonPressed) {
// calculate new {_x, _y} position
repaint();
}
} else super::mouseMoveEvent(event);
}
void MyQLabel::paintEvent(QPaintEvent *aEvent){
QPainter paint(this);
paint.drawPixmap(_x, _y, pixMap);
}
... // Somewhere in the code:
MyQLabel _myLabel(NULL);
_myLabel.showFullScreen();
_myLabel.show();
It feels like QGraphicsView is skipping the over some positions (with fast dragging), while QLabel paints at all intermediate images.
What do I miss?
Thank you Alex