12

私は QT を学んでおり、パン中の QLabel と QGraphics ビューのパフォーマンスの違いに戸惑っています。

巨大な 36Mpixels (D800) jpeg ファイルを QLabel または QGraphics オブジェクトに読み込み、QLabel/Graphics でフルスケールの画像をドラッグしようとしました。驚いたことに、QGRaphicsView のパンニングはぎくしゃくしているのに対し、QLabel は非常にスムーズな動きを提供します。

簡略化された QGraphicsView コードは次のとおりです。

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

簡略化された QLabel ベースのコードは次のとおりです。

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

QGraphicsView がいくつかの位置を (高速ドラッグで) スキップしているように感じますが、QLabel はすべての中間画像をペイントします。

何が恋しいですか?

ありがとうアレックス

4

1 に答える 1