dekomote
dekomote

Reputation: 4017

How can I grab a QPixmap of a widget that's hw overlayed?

I am trying to grab a QPixmap of a widget, but the widget is hw overlayed. It used to work, up until I switched graphic cards. The code in question is:

...
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
ui->viewFinder->grab().save(&buffer, "JPG");
...

The viewfinder widget is a QCameraViewfinder. Qt4 widgets application on Archlinux. Is there any way to disable overlaying on a specific widget, or a way to capture it? Trying to capture it with ksnapshot works.

Upvotes: 1

Views: 154

Answers (1)

dekomote
dekomote

Reputation: 4017

Apparently, I had to ask a question to solve the problem.

QPixmap::grabWindow grabs the widget even if it's hardware overlayed. I dug the info out of the ksnapshot source code.

So the example code will be:

QPixmap::grabWindow(ui->viewFinder->winId(), 0, 0, -1, -1).save(&buffer, "JPG");

Upvotes: 1

Related Questions