[Interest] How can i manipulate pixel data from a QWidget?

Josiah Bryan josiahbryan at gmail.com
Sat Sep 22 21:15:55 CEST 2012

Subclass QWidget::paintEvent(QPaintEvent*) (
http://doc.qt.digia.com/4.6/qwidget.html#paintEvent) and do your own
painting of the widget. See the Analog Clock example (
http://doc.qt.digia.com/4.7-snapshot/widgets-analogclock.html) for an
example on how to draw the contents of the widget.

If you're wanting to do per-pixel work - the easiest (only?) way is via a
QImage - there is no direct per pixel access to video memory. The closest
thing you'll get to direct-pixel access of video memory is to use a
QGLWidget and implement pixel shaders.

On Sat, Sep 22, 2012 at 3:00 PM, Mark <markg85 at gmail.com> wrote:

> Hi,
> I know one can manipulate pixel data in a QImage using the bits()
> function, but how can i do the same for a QWidget?
> I want to play with a high performance line drawing algorithm [1] so i
> guess it's not very optimal to do the following:
> - draw in a QImage
> - put that image in the qwidget
> - further drawing in the QImage
> - put it on the QWidget again
> - ... and so on ...
> In this case i'm guessing that the QImage mapping to a QWidget would
> be the most costly one hence i'd like to prevent that altogether and
> "just" manipulate the QWidget pixel data directly.
> So how do i do that?
> Cheers,
> Mark
> [1] http://free.pages.at/easyfilter/bresenham.html
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

Josiah Bryan
josiahbryan at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120922/664fdf0a/attachment.html>

More information about the Interest mailing list