Hi Zhiming,
Trying to do the screenshot with Qt5, I've made a small app, here is the function implementation that I connect to a ButtonReleased signal:
QScreen *screen = QGuiApplication::primaryScreen();
auto geom = screen->geometry();
QPixmap screenGrab = screen->grabWindow(0, geom.x(), geom.y(), geom.width(), geom.height());
screenGrab.save("screenshot.png");
I compile and run the code for both platform my dev_laptop and the iMX8M board. On my laptop I can see a png file being created, all good. Exact same code on the imx board, I have the same window with my button but no png file created. "screenGrab" is NULL!
What am I missing? Isn't it the right way to get the "screen"? What's the difference? My dev_=Laptop has x11 for XDG_SESSION_TYPE while on the board echo $XDG_SESSION_TYPE returns "tty" (weird).
Please let me know.
Thank you,
Sebastien.