How to take snapshot of the whole GUI
-
I have QT GUI and QMainWindow and have multiple windows inside it . I would like to take snapshot of the whole GUI and save it png format
Could you let me know how is to be done
-
Hi, Screenshot Example may help.
Regards. -
Hi,
QPixmap *pixmap = new QPixmap(this->size()); this->render(pixmap);
inside your Gui-Class should do the trick.
-
For Mainwindow
-
I would like to take snapshot of the whole GUI
If this means to include window frames, try this:
void Mainwindow::screenShot() { QRect geo = frameGeometry(); qApp->primaryScreen()->grabWindow(0, geo.x(), geo.y(), geo.width(), geo.height()).save("test.png"); }
-
how to get qApp pointer If I am accessing Mainwindow poiter some other QWidget
-
Hi @Qt-Enthusiast
include bellow line to your mainWindow class then you will get qApp pointer.
#include<QApplication> -
I am getting following error
gui/qt4/qmain/GQMainWindow.cc: In member function ?void GQMainWindow::copy()?:
gui/qt4/qmain/GQMainWindow.cc:959:10: error: ?class QApplication? has no member named ?primaryScreen?
qApp->primaryScreen()->grabWindow(0,geo.x(),geo.y(),geo.width(),geo.height()).save("test.png");
^ -
it is qt.4.3.3
-
Hi,
For me it works fine.
Try with including both headers,
#include <QApplication>
#include <QScreen> -
Unfortunately, the
QScreen
is not supported in Qt 4.3.3.
However, you can useQPixmap
instead ofQScreen
. But I can't guarantee it. I'm not currently using Qt 4.3.3.The
qApp
is equivalent to the pointer returned by theQCoreApplication::instance()
or theQApplication::instance()
function. -
Why not simply use Windows Key and PrtScr - does it have to be coded?