Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
does QT5 deliver any high-level way to capture screen, like with PrintScreen?
What do you mean by high level way ?
With Qt5 you can take screenshots with help of "QScreen":http://qt-project.org/doc/qt-5/qscreen.html.
Have a look at this "example":http://doc.qt.digia.com/qt-5.2/qtwidgets-desktop-screenshot-screenshot-cpp.html.
Also this example would be in <QtDir>/Qt5.3.0/Examples/Qt-5.3/widgets/desktop/screenshot if you have installed Qt 5.3
Use QScreen and grabWindow function. It should satisfy your requirement
Thank you. It's great for Linux, I don't have to use Imlib2 manually or something.
But I have one doubt. I know that WId for whole screen in example is 0. But does this number it work outside X11?
bq. But does this number it work outside X11?
Didnt understand what you mean ?
Above example works on Windows too.
@ if (screen)
originalPixmap = screen->grabWindow(0);
There is nothing about value of WId that should be used to capture whole screen, so I figured out that this can be environment-depended.
In example as "WId" of whole screen is used 0, but why do I can be sure that it will work everywhere?
Besides, where is WId defined/descripted?
I too see there's no documentation for WId. But i think it could just be a Hexadecimal number. Well it works atleast on Linux and Windows platforms. Never tested on other platforms.
But do you want to take screenshots of individual windows or the screens? Since as per docs,
bq. The grabWindow() function grabs pixels from the screen, not from the window, i.e. if there is another window partially or entirely over the one you grab, you get pixels from the overlying window, too. The mouse cursor is generally not grabbed.
So the screen which you want to capture should not be obstructed by other window or else its contents gets capture too.
To be honest, I want to do almost exactly the same work in my code as does "scrot -s" command on Ubuntu. I could use scrot code which is on MIT license, but it isn't multiplatform (it work only with X11).