Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Taking screenshot of a specific window - C++ / Qt

Tags:

c++

screenshot

qt

In Qt, how do I take a screenshot of a specific window (i.e. suppose I had Notepad up and I wanted to take a screenshot of the window titled "Untitled - Notepad")? In their screenshot example code, they show how to take a screenshot of the entire desktop:

originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId());

How would I get the winId() for a specific window (assuming I knew the window's title) in Qt?

Thanks

like image 635
Switch Avatar asked Nov 21 '09 01:11

Switch


1 Answers

I'm pretty sure that's platform-specific. winIds are HWNDs on Windows, so you could call FindWindow(NULL, "Untitled - Notepad") in the example you gave.

like image 166
ChrisV Avatar answered Sep 24 '22 00:09

ChrisV