PDA

View Full Version : QPixmap::grabWindow too slow



niko
30th August 2006, 21:19
Hello,

I have a widget, that makes a screenshot every second and paints it out:


ZoomWidget::ZoomWidget(QWidget* parent) : QWidget(parent)
{
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(1000);
}

void ZoomWidget::paintEvent(QPaintEvent * /*event*/) {
QPainter painter(this);
painter.drawPixmap(0, 0, QPixmap::grabWindow(QApplication::desktop()->winId()), 0, 0, 100, 100);

}


it works, but slows down my system quite a lot (every second a small lag)

if i change the interval to 1ms, X has 100% percent processor-load.

how could i speed up this?

(i took a look at kmag - which does basically the same thing in qt3 and is much faster - not really fast either - but still better)

niko

wysota
30th August 2006, 22:50
Get a snapshot only when you need it. It is very expensive to grab the desktop widget.

niko
31st August 2006, 06:40
thanks, that helped a lot!
(i could have thought about that myselfe...)

niko