我是Qt / C++编程的初学者,我想使用Qt获取窗口的屏幕截图。
#include <qapplication.h>
#include <qpushbutton.h>
int main( int argc, char **argv )
{
QApplication a( argc, argv );
QPushButton hello( "Hello world!", 0 );
hello.resize( 100, 30 );
a.setMainWidget( &hello );
hello.show();
return a.exec();
}
有人可以帮我吗?
最佳答案
这是获取特定窗口的屏幕快照的一种简短方法:
/* Take a screenshot of a window
Notice that window is a: QWidget *window; */
originalPixmap = QPixmap::grabWidget(window);
关于c++ - 如何为窗口截图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60204598/