当前位置: 首页 > news >正文

手机在线销售网站 - 百度本地wordpress 慢

手机在线销售网站 - 百度,本地wordpress 慢,苏州做网站哪家好,苏州seo招聘效果 生成一个透明无边框全屏的窗口#xff0c;然后按ctrlb键就可以选择区域进行截图保存 步骤 新建一个项目新建一个ctrlb类继承QMainWindow新建一个CaptureScreen类继承QWidget在main中启动ctrlb类 代码 ctrlb类.cpp #include ctrlb.h #include cap…效果 生成一个透明无边框全屏的窗口然后按ctrlb键就可以选择区域进行截图保存 步骤 新建一个项目新建一个ctrlb类继承QMainWindow新建一个CaptureScreen类继承QWidget在main中启动ctrlb类 代码 ctrlb类.cpp #include ctrlb.h #include capturescreen.h #include QKeyEvent #include QPixmap #include QFileDialog #include QProcess #include QDebug #include QFile #include QTextStreamctrlb::ctrlb(QWidget *parent): QMainWindow(parent) {}// 按键事件 void ctrlb::keyPressEvent(QKeyEvent *event) {if (event-key() Qt::Key_B event-modifiers() Qt::ControlModifier) {triggerScreenshot();} } // 截图操作 void ctrlb::triggerScreenshot() {// 定义截图对象CaptureScreen *capture new CaptureScreen();// 调用 close() 函数或用户点击关闭按钮时窗口对象会被自动销毁capture-setAttribute(Qt::WA_DeleteOnClose); // 当完成截图操作后会发送信号触发保存图片connect(capture, CaptureScreen::signalCompleteCature, this, ctrlb::handleScreenshot);// 显示截图窗口capture-show(); } // 保存图片参数是屏幕的截图 void ctrlb::handleScreenshot(const QPixmap screenshot) {// 判断参数是否为空if (!screenshot.isNull()) {QString savePath check.jpg;if (!savePath.isEmpty()) {// 保存为用户指定的文件screenshot.save(savePath, JPG); }}}ctrlb类.h #ifndef CTRLB_H #define CTRLB_H#include QMainWindowclass ctrlb : public QMainWindow {Q_OBJECT public:explicit ctrlb(QWidget *parent nullptr);protected:void keyPressEvent(QKeyEvent *event) override;private:void triggerScreenshot();private slots:// 保存图片槽函数void handleScreenshot(const QPixmap screenshot); };#endif // CTRLB_HCaptureScreen类.cpp #include capturescreen.h #include QApplication #include QMouseEvent #include QPixmap #include QScreenCaptureScreen::CaptureScreen(QWidget *parent): QWidget(parent), m_isMousePress(false) {// 初始化窗口initWindow();//loadBackgroundPixmap(); }CaptureScreen::~CaptureScreen() {}void CaptureScreen::initWindow() {// 启用鼠标跟踪移动的时候也会触发事件this-setMouseTracking(true);// 设置窗口为无边框模式this-setWindowFlags(Qt::FramelessWindowHint);// 设置窗口全屏显示setWindowState(Qt::WindowActive | Qt::WindowFullScreen); } // 抓取当前桌面内容作为背景快照 void CaptureScreen::loadBackgroundPixmap() {// 获取当前主屏幕的 QScreen 对象QScreen *screen QGuiApplication::primaryScreen();if (screen) {// 获取现在的整个屏幕m_loadPixmap screen-grabWindow(0);}// 获取屏幕宽高m_screenwidth m_loadPixmap.width();m_screenheight m_loadPixmap.height(); }// 处理鼠标左键按下记录起点位置 void CaptureScreen::mousePressEvent(QMouseEvent *event) {// 判断是不是左键if (event-button() Qt::LeftButton){// 画图标志m_isMousePress true;// 记录起始位置m_beginPoint event-pos();}return QWidget::mousePressEvent(event); }// 处理鼠标移动记录终点位置 void CaptureScreen::mouseMoveEvent(QMouseEvent* event) {// 判断是否画图if (m_isMousePress){// 记录移动位置m_endPoint event-pos();// 画矩形update();}return QWidget::mouseMoveEvent(event); }// 处理鼠标松开记录终点位置 void CaptureScreen::mouseReleaseEvent(QMouseEvent *event) {// 记录结束位置m_endPoint event-pos();// 结束画矩形m_isMousePress false;return QWidget::mouseReleaseEvent(event); }// 绘制事件 void CaptureScreen::paintEvent(QPaintEvent *event) {// 初始化 QPainter 对象 m_painterm_painter.begin(this);// 半透明的黑色阴影用于覆盖整个屏幕QColor shadowColor QColor(0, 0, 0, 100);// 设置画笔m_painter.setPen(QPen(Qt::blue, 1, Qt::SolidLine, Qt::FlatCap));// 将获取到的屏幕放到窗口上m_painter.drawPixmap(0, 0, m_loadPixmap);// 绘制一个半透明的黑色矩形m_painter.fillRect(m_loadPixmap.rect(), shadowColor);// 如果鼠标正在移动会绘制选中的矩形区域if (m_isMousePress){// 计算选区矩形QRect selectedRect getRect(m_beginPoint, m_endPoint);// 保存选区内容m_capturePixmap m_loadPixmap.copy(selectedRect);// 将选区内容绘制到窗口m_painter.drawPixmap(selectedRect.topLeft(), m_capturePixmap);// 绘制选区边框m_painter.drawRect(selectedRect);}// 释放对象m_painter.end(); //重绘结束; }// 键盘事件 void CaptureScreen::keyPressEvent(QKeyEvent *event) {// Esc 键退出截图;if (event-key() Qt::Key_Escape){close();}// Enter键完成截图;if (event-key() Qt::Key_Return || event-key() Qt::Key_Enter){// 保存截图为 JPG 格式QString savePath screenshot.jpg;if (!m_capturePixmap.isNull()) {// 保存为 JPG 格式m_capturePixmap.save(savePath, JPG);}// 发送截图完成信号emit signalCompleteCature(m_capturePixmap);close();} }// 计算一个矩形区域并返回 QRect CaptureScreen::getRect(const QPoint beginPoint, const QPoint endPoint) {// 矩形的左上角坐标、宽度和高度int x, y, width, height;width qAbs(beginPoint.x() - endPoint.x());height qAbs(beginPoint.y() - endPoint.y());x beginPoint.x() endPoint.x() ? beginPoint.x() : endPoint.x();y beginPoint.y() endPoint.y() ? beginPoint.y() : endPoint.y();// 创建矩形对象QRect selectedRect QRect(x, y, width, height);// 避免宽或高为零时拷贝截图有误设置最小为1if (selectedRect.width() 0){selectedRect.setWidth(1);}if (selectedRect.height() 0){selectedRect.setHeight(1);}// 返回矩形对象return selectedRect; }CaptureScreen类.h #ifndef CAPTURESCREEN_H #define CAPTURESCREEN_H#include QWidget #include QPainterclass CaptureScreen : public QWidget {Q_OBJECTpublic:CaptureScreen(QWidget *parent 0);~CaptureScreen();Q_SIGNALS:void signalCompleteCature(QPixmap catureImage);private:void initWindow();void loadBackgroundPixmap();void mousePressEvent(QMouseEvent *event);void mouseMoveEvent(QMouseEvent* event);void mouseReleaseEvent(QMouseEvent *event);void keyPressEvent(QKeyEvent *event);void paintEvent(QPaintEvent *event);QRect getRect(const QPoint beginPoint, const QPoint endPoint);private:bool m_isMousePress;// 判断鼠标是否移动和是否画矩形QPixmap m_loadPixmap;// 整个屏幕的图像QPixmap m_capturePixmap;// 框选的屏幕图像int m_screenwidth;// 屏幕的宽int m_screenheight;// 屏幕的高QPoint m_beginPoint, m_endPoint;// 起点和结束点坐标QPainter m_painter;// 画图对象 };#endif // CAPTURESCREEN_Hmain #include mainwindow.h#include QApplication #include ctrlb.h #include QDebug #include QWidgetint main(int argc, char *argv[]) {QApplication a(argc, argv);qDebug()init;ctrlb w;// 设置无边框窗口w.setWindowFlags(Qt::FramelessWindowHint); // 全屏w.showFullScreen();// 背景透明w.setAttribute(Qt::WA_TranslucentBackground);// 设置透明度w.setWindowOpacity(1); w.show();return a.exec(); }
http://www.hkea.cn/news/14350460/

相关文章:

  • 房产中介网站开发费用苏州建设交通职业技术学院
  • 云梦县城乡建设局网站凡科快图在线制作免费官网下载
  • 巴中微小网站建设案例彩票网站html模板
  • 百度做网站和推广效果怎么样vue.js做网站
  • 网站建设实训报告目的网站突然被降权
  • 哈尔滨建筑专业网站移动网站建设推广
  • 概述网站建设的流程永久无限免费看的app
  • 列出寻找网站关键词的几种途径wordpress 增加数据表
  • 站长工具无吗经典高端旅游定制网站
  • 东莞企业网站seo手机端网站开发教程
  • 找人做网站需要注意什么权大师的网站是哪个公司做的
  • 网站seo 优帮云律师论坛网站模板
  • 长沙优化网站方法网站建设各模块功能简述
  • 企业电子网站的建设案例济南哪里有网站建设公司
  • cms类型网站开发住房城乡建设厅官方网站
  • 展示型网站制作公司规模以上工业企业的标准是什么
  • 包头焦点网站建设基于asp的医疗网站开发
  • top的域名网站做视频的教学直播网站
  • 网站订单模板企业建设网站的资金策划
  • 企业网站建设免费会计培训
  • 上海信息科技有限公司软件网站开发wordpress文章不显示发布时间
  • 做英语作业的网站企业网站站内优化
  • 建设家具网站的目的及功能定位做引流去那些网站好
  • html5简单网页大作业seo优化心得
  • 胶州为企业做网站的公司网站建设相关费用预算推广
  • 西安大网站建设公司wordpress快速登录插件
  • 视频封面制作网站企业宣传文案模板
  • 在哪里创建网站平台wordpress改造微博主题
  • 网站安全检测工具网站做友链有行业要求吗
  • 网站建设合同附加协议中关村在线手机对比平台