c++ - 如何为窗口截图

标签 c++ qt

我是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/

相关文章:

qt - 动画高度

qt - Qt4中QTextDocument单页表格和图片

android - 未定义的函数引用 Android NDK

c++ - DEV C++ 编译但 Visual Studio 不

c++ - C++ 中的异常处理 Terminate 在抛出 'char const*' 的实例后调用

c++ - libssh2 - 使用 SFTP 读取文件

C++ 跨边界使用 std::vector

c++ - 错误 : lvalue required as left operand of assignment what to do

c - GTK 中的信号和槽

c++ - nmake 无法工作 - Qt