Hi, all!
I have an application - shapes viewer. My app consists of two main components. There are OpenGL Viewer and Qt/Qml toolbar. I am trying to take screenshot of my app.
First time I have tried this one:
QQuickWindow* window = this->window();
if (window)
{
QImage image
= window
->grabWindow
();
image.
save(QString(path
));
// The path is valid }
QQuickWindow* window = this->window();
if (window)
{
QImage image = window->grabWindow();
image.save(QString(path)); // The path is valid
}
To copy to clipboard, switch view to plain text mode
At the first launch of the app the screenshot was taken properly, but app was frozen. On the next launches app was freezing without taking screenshot. The app is freezing when I am calling
QImage image
= window
->grabWindow
();
QImage image = window->grabWindow();
To copy to clipboard, switch view to plain text mode
Also, I have tried, but it is doesn't work:
QScreen *screen
= QGuiApplication
::primaryScreen();
if(screen)
{
QPixmap originalPixmap
= screen
->grabWindow
(this
->window
()->winId
());
if(originalPixmap.
save(QString(path
))) {
qDebug
() <<
QString("Screenshot saved");
}
else
{
qDebug
() <<
QString("Screenshot not saved");
}
}
QScreen *screen = QGuiApplication::primaryScreen();
if(screen)
{
QPixmap originalPixmap = screen->grabWindow(this->window()->winId());
if(originalPixmap.save(QString(path)))
{
qDebug() << QString("Screenshot saved");
}
else
{
qDebug() << QString("Screenshot not saved");
}
}
To copy to clipboard, switch view to plain text mode
Please, help to solve this problem
Bookmarks