qt 将当前窗口保存为图片
bool BasicDotChart::saveAsImage(const QString &path) { // 获取窗口的 QPixmap QPixmap pixmap = this->grab(); // 弹出保存文件对话框,选择保存位置和文件格式 QString filePath = path + "/" + QDateTime::currentDateTime().toString("yyyy-mm-dd-hh-mm-ss") + "_dotchat.png"; qDebug()<<"filePath = "<<filePath; if (!filePath.isEmpty()) { // 保存 QPixmap 到文件 pixmap.save(filePath); qDebug()<<"点位图保存成功 : "<<filePath; return true; } qDebug()<<"点位图保存失败!"; return false; }