QDir dir;
if (!dir.exists("image"))
{
dir.mkpath("image");
}
if (!dir.exists("image/imagecapture/"))
{
dir.mkpath("image/imagecapture/");
}
QScreen* screen = QGuiApplication::primaryScreen();
QString saveTime = QDateTime::currentDateTime().toString("yyyy-MM-dd hh-mm-ss");
QString imagePath = "image/imagecapture/"+ saveTime + ".jpg";
screen->grabWindow(0).save(imagePath);
if (dir.exists(imagePath))
{
emit screenCaptureDone();
}
Qt截屏功能
于 2022-12-15 16:54:07 首次发布