Qt截屏功能

        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,开发语言)