截取屏幕思路

x4control 2011-07-21 11:13:00
我要写个屏幕截取的小程序 刚接触qt' 望大家不吝赐教
...全文
63 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
pinkwhitecat 2011-07-22
  • 打赏
  • 举报
回复
谢谢你了
lovelyann 2011-07-22
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 yiyaaixuexi 的回复:]
C/C++ code


#include <QFileDialog>
#include <QDir>
#include <QMessageBox>


Screenshot::Screenshot(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Screenshot)
{
ui->setupUi……
[/Quote]

学习了。。
dext 2011-07-22
  • 打赏
  • 举报
回复
QtDir\examples\desktop\screenshot
念茜 2011-07-21
  • 打赏
  • 举报
回复

#include <QFileDialog>
#include <QDir>
#include <QMessageBox>


Screenshot::Screenshot(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Screenshot)
{
ui->setupUi(this);
QObject::connect(ui->shotScreenButton,SIGNAL(clicked()),this,SLOT(newShotScreenSlot()));
QObject::connect(ui->saveButton,SIGNAL(clicked()),this,SLOT(saveScreenSlot()));

}

Screenshot::~Screenshot()
{
delete ui;
}

void Screenshot::newShotScreenSlot()
{
if(ui->hideCheckBox->isChecked())
{
this->hide();
this->timer =new QTimer;

QObject::connect(this->timer,SIGNAL(timeout()),this,SLOT(shotScreenSlot()));
this->timer->start(ui->timeSpinBox->value()*1000);

}
else
{
qApp->beep();
}
}

void Screenshot::shotScreenSlot()
{
this->pixmap= QPixmap::grabWindow(QApplication::desktop()->winId());
ui->screenLabel->setPixmap(pixmap.scaled(ui->screenLabel->size()));
this->timer->stop();
this->show();
}

void Screenshot::saveScreenSlot()
{
QString fileName=QFileDialog::getSaveFileName(this,"Screen Save",QDir::currentPath());
if(!fileName.isEmpty())
{
pixmap.save(fileName);
}
else
{
QMessageBox::information(this,"Error Message","Select a name ");
return;
}

}

16,203

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧