0

グラフィック全体を再描画するのではなく、新しいオブジェクトのみを描画したいと考えています。これは、たとえば QPainter の描画によって行われます。QWidget または他の単純な QPaintDevice の paintEvent() イベント。

しかし、すべてを何度も何度も描画する代わりに、既存のポイントに新しいポイントを追加するには、どのペイント デバイスまたはその他のオブジェクトを使用すればよいでしょうか?

4

2 に答える 2

2

Essentially what Reto said, with the following additional considerations:

  1. PaintDevices that you can use as the cache: http://qt-project.org/doc/qt-4.8/qpaintdevice.html lists the possible options of the paintDevices that can be painted to using QPainter. The ones you are looking for are probably: QImage, QPixmap, QPicture and even the OpenGL related PaintDevices, in case you are using hardware accelerated widgets. QImage is recommended in case you are going to perform a blit, and need direct pixel data access but, otherwise, for simple QPainter operations, QPixMap is faster.

  2. Actually painting the new points from cache that you've got: Have a look at the relevant draw{Image/Picture/Pixmap} api's of QPainter, that you can use to draw the PaintDevice that you have cached onto in the first place. Use the QPaintEvent::region from the paintEvent obtained in the paintEvent call of the widget to get the rectangle that you need to copy over from the cache, keeping in mind that, if you are sending update requests yourself, use the appropriate update function to trigger the paintEvent.

于 2013-03-23T04:07:18.593 に答える
1

QImage をキャッシュとして使用します。したがって、最初に最初の「ポイント」を画像にペイントしてから、画像をウィジェットに描画します。新しい「ポイント」を取得したら、新しい「ポイント」を画像にペイントし、その画像をウィジェットにペイントします。

于 2013-03-22T17:03:44.593 に答える