QLabel and QGraphicsView performance

I am learning QT, and I am puzzled by the difference in the performance of QLabel and QGraphics during panning.

I read a huge 36Mpixels (D800) JPEG file in QLabel or QGraphics objects and try to drag a full-size image using QLabel / Graphics. Surprisingly, QLabel provides very smooth movement, while QGRaphicsView panning is jerky.

Simplified QGraphicsView Code:

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(); 

Simplified QLabel-based code:

 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 seems that QGraphicsView skips some positions (with fast drag and drop), and QLabel draws on all intermediate images.

What am I missing?

Thanks. Alex

+6
source share

Source: https://habr.com/ru/post/925881/


All Articles