1

描画に多くの処理が必要な大規模で複雑なグラフィックス ビューがあるため、フレームごとにその一部 (OpenGL ビデオ ディスプレイ) のみを再描画し、残り (さまざまな子ウィジェットなど) は変更しません。

ただし、QRegion で update() を呼び出すと、paintEvent の領域がウィジェットのフル サイズになるため、画面全体が毎回再描画されます。パラメーターなしで update() を呼び出すことはないようです (少なくとも、私のバージョンではありません)。

ペイント イベントで全画面が表示される原因は何ですか?

void GLGraphicsView::updateVideoRegion(const QRegion & r)
{
    //this function called from outside...
    LOG4CXX_DEBUG(_logger, "updateVideoRegion " << r.boundingRect().x() << " " << r.boundingRect().y() << " " << r.boundingRect().width() << " " << r.boundingRect().height());
    update(r);  
}

void GLGraphicsView::update()
{
    LOG4CXX_DEBUG(_logger, "update(all)");
    QGraphicsView::update();
}

void GLGraphicsView::update(const QRegion& region)
{
    LOG4CXX_DEBUG(_logger, "update(region) " << region.boundingRect().x() << " " << region.boundingRect().y() << " " << region.boundingRect().width() << " " << region.boundingRect().height());
    QGraphicsView::update(region);
}

void GLGraphicsView::paintEvent(QPaintEvent *e)
{
    LOG4CXX_DEBUG(_logger, "repaint region " << e->region().boundingRect().x() << " " << e->region().boundingRect().y() << " " << e->region().boundingRect().width() << " " << e->region().boundingRect().height());

    /* Do the rest of the painting */
}

出力:

updateVideoRegion 19 19 1446 568
update(region) 19 19 1446 568
repaint region 0 0 1920 1201

編集:

また、viewportUpdateMode を SmartViewportUpdate に設定して、update(QRegion) の代わりに updateScene(QList) を使用してみましたが、paintEvent の領域はまだ画面のフル サイズです。CacheMode は CacheNone に設定されており、それを CacheBackground に設定すると、OpenGL が表示されなくなります。

4

1 に答える 1

0

さらに調査した結果、これは私が OpenGL を使用しているためであると思われます。この場合、updateScene の「fullUpdate」フラグは常に設定されています。 ->accelerateScrolling" [updateScene、2675 行目]

于 2016-01-15T14:12:43.527 に答える