Reputation: 51
I'm trying to run this code:
QPixmap ss = QScreen::grabWindow((WId) FindWindow(NULL, L"Blacklight Retribution"));
ss.save("haystack.png", "png");
but I am getting this error:
error: C2352: 'QScreen::grabWindow' : illegal call of non-static member function
Upvotes: 4
Views: 5171
Reputation: 1611
Qt 5 has updated Screenshot example and shootScreen function looks as the following:
void Screenshot::shootScreen()
{
QScreen *screen = QGuiApplication::primaryScreen();
if (const QWindow *window = windowHandle())
screen = window->screen();
if (!screen)
return;
originalPixmap = screen->grabWindow(0);
updateScreenshotLabel();
}
Upvotes: 2
Reputation: 11161
You could try something like this:
QScreen *screen = QGuiApplication::primaryScreen();
if (screen)
{
QPixmap ss = screen->grabWindow((WId) FindWindow(NULL, L"Blacklight Retribution"));
}
Upvotes: 4