【发布时间】:2015-12-03 08:58:04
【问题描述】:
我想将当前窗口保存到 Qt 中的图像(如 ATL+PrintScreen)。例如Qt Media Player Example(搜索“播放器”时可以得到Qt Creator示例中的所有代码,我将此代码添加到player.h:
//private slots:
...
void exportVideoToImages();
在player.cpp:
void Player::exportVideoToImages()
{
qDebug() << "ok";
QPixmap const& px = grab();
px.save("File.png");
}
将此行添加到构造函数以触发插槽:
new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_G), this, SLOT(exportVideoToImages()));
所以,当我触发 CTRL+G 时,我会收到一个图像“File.png”。它工作,但问题是无法捕捉播放的视频。
这是两张图片,一张来自 Alt+PrintScreen,一张来自程序:
为什么会这样?如何在 Qt 中抓取视频?能给我看看吗?
非常感谢!
【问题讨论】:
标签: c++ qt video-capture