void ScreenShotPage::takeScreenshot() { QPixmap screenshot; screenshot = QPixmap::grabWindow(scene()->views().at(0)->effectiveWinId()); QString path; if (QDir(ImagesPath).exists()) path = ImagesPath; else path = QDir::homePath(); QString fileFormat(QString("%1/%2-%3.png").arg(path).arg(QDate::currentDate().toString("yyyyMMdd")).arg(QTime::currentTime().toString("hhmmss"))); if (!screenshot.save(fileFormat)) mWarning("MWindow") << "Could not save screenshot to" << path; playScreenshotEffect(); MBanner * bannerPath = new MBanner(); bannerPath->setObjectName("pathBanner"); bannerPath->setStyleName("InformationBanner"); bannerPath->setTitle("Screenshot has been saved in: " + fileFormat); bannerPath->appear(scene(), MSceneWindow::DestroyWhenDone); }