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

免费的做网站google play商店

免费的做网站,google play商店,河南移动官网网站建设,个人网站备案号被注销了6.1 QPaintEvent 绘图事件 QPaintEvent 是 Qt 框架中一个重要的事件类,专门用于处理绘图事件。当 Qt 视图组件需要重绘自己的一部分时,就会产生 QPaintEvent 事件。这通常发生在以下几种情况: 1. 窗口第一次显示时 :当窗口…
6.1 QPaintEvent 绘图事件
QPaintEvent Qt 框架中一个重要的事件类,专门用于处理绘图事件。当 Qt 视图组件需要重绘自己的一部分时,就会产生 QPaintEvent 事件。这通常发生在以下几种情况:
1. 窗口第一次显示时 :当窗口或控件第一次出现在屏幕上时,系统会生成一个 QPaintEvent 事件,通知窗口进行自身的绘制。
2. 窗口大小改变时 :当用户改变窗口的大小时,窗口的内容通常需要重新绘制以适应新的尺寸。
3. 窗口部分被遮挡后又重新显示时 :如果窗口被其他窗口遮挡,然后又重新露出来,被遮挡的部分通 常需要重新绘制。
4. 手动请求重绘 :通过调用 QWidget update() repaint() 方法,可以手动触发重绘事件。
Qt 应用程序中,通常通过重写 QWidget paintEvent(QPaintEvent *) 方法来处理绘制逻辑。
例如:
class MyWidget : public QWidget {
protected :
        void paintEvent ( QPaintEvent * event ) override {
                QPainter painter ( this );
                // 绘制逻辑
        }
};
paintEvent 方法中,您可以创建一个 QPainter 对象并使用它来执行绘制操作。 QPainter 可以绘制各种基本图形,如线条、矩形、椭圆等,还可以绘制文本和图像。重写 paintEvent 是在 Qt 中进行自定义绘制的标准做法。
6.2 QPainter 画家
6.2.1 概述
QPainter Qt 库中用于在屏幕上进行绘画的类。它提供了各种绘制功能,比如画线、画图形、画文本等。
以下是一些基本的用法示例:
1. 初始化 QPainter :首先,您需要一个 QPaintDevice ,比如一个 QWidget QPixmap ,然后使用它来初始化 QPainter 对象。
QPainter painter ( this ); // 假设在 QWidget 的子类中
设置画笔和画刷 :您可以设置画笔(用于描边)和画刷(用于填充)的颜色、样式等。
painter . setPen ( Qt::blue ); // 设置画笔颜色为蓝色
painter . setBrush ( Qt::yellow ); // 设置画刷颜色为黄色
绘制图形 :使用 QPainter 的方法来绘制线条、矩形、圆形、文本等。
painter . drawLine ( 10 , 10 , 100 , 100 ); // 画线
painter . drawRect ( 10 , 10 , 100 , 100 ); // 画矩形
painter . drawText ( 10 , 10 , "Hello, Qt!" ); // 画文本
结束绘制:完成绘制后, QPainter 对象会在其析构函数中自动结束绘制。
请注意, QPainter 的使用依赖于 Qt 的事件循环,因此通常在 QWidget paintEvent 或者类似的事件处理函数中使用它。如果您在 Qt 应用程序中使用 QPainter ,请确保您遵循 Qt 的事件驱动机制。
以下还有画线,画矩形,画圆,画弧线,画扇形的代码案例:
#include "widget.h"
#include "ui_widget.h"
 
#include <QPainter>
 
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}
 
Widget::~Widget()
{
    delete ui;
}
 
void Widget::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    //设置画笔颜色,大小
//    QPen pen(Qt::lightGray,7);
//    painter.setPen(pen);
    painter.setPen(Qt::lightGray);
    //设置字体大小
    painter.setFont(QFont("Arial", 30));
    //写字
    painter.drawText(rect(), Qt::AlignCenter, "Qt");
 
    //画线
//    void drawLine(const QLine &line)
    QLine line(10,100,200,10);
    painter.drawLine(line);
//    void drawLine(int x1, int y1, int x2, int y2)
    painter.drawLine(100,400,200,10);
//    void drawLine(const QPoint &p1, const QPoint &p2)
    painter.drawLine(QPoint(100,400),QPoint(10,100));
 
    //画矩形
//    void  drawRect(int x, int y, int width, int height)
    painter.drawRect(100,100,20,100);
//    void drawRect(const QRect &rectangle)
    QRect rect(100,100,40,200);
    painter.drawRect(rect);
 
    //画圆
//    void drawEllipse(const QRect &rectangle)
    QRect ellipse(200,200,50,100);
    painter.drawEllipse(ellipse);
//    void drawEllipse(int x, int y, int width, int height)
    painter.drawEllipse(250,200,50,100);
//    void drawEllipse(const QPoint &center, int rx, int ry)
    painter.drawEllipse(QPoint(250,200),100,200);
 
    //画弧线
//    void drawArc(const QRect &rectangle, int startAngle, int spanAngle)
    QRect arc(200,100,100,50);
    painter.drawArc(arc,30*16,120*16);
    painter.drawArc(arc,-30*16,-120*16);
//    void drawArc(int x, int y, int width, int height, int startAngle, int spanAngle)
    painter.drawArc(200,120,100,50,30*16,120*16);
    painter.drawArc(200,120,100,50,-30*16,-120*16);
 
    //画扇形
//    void drawPie(int x, int y, int width, int height, int startAngle, int spanAngle)
    painter.drawPie(200,220,100,50,30*16,120*16);
//    void drawPie(const QRect &rectangle, int startAngle, int spanAngle)
    QRect pie(200,250,100,50);
    painter.drawPie(pie,30*16,120*16);
 
}
 
 

文章转载自:
http://artistic.sqxr.cn
http://edile.sqxr.cn
http://vernally.sqxr.cn
http://kangarooing.sqxr.cn
http://neuroregulator.sqxr.cn
http://claudine.sqxr.cn
http://esoteric.sqxr.cn
http://pokesy.sqxr.cn
http://changeful.sqxr.cn
http://investigator.sqxr.cn
http://incorruptness.sqxr.cn
http://tramontana.sqxr.cn
http://biwa.sqxr.cn
http://not.sqxr.cn
http://rheobase.sqxr.cn
http://stilt.sqxr.cn
http://playbus.sqxr.cn
http://elamitish.sqxr.cn
http://ldh.sqxr.cn
http://closefisted.sqxr.cn
http://hellenic.sqxr.cn
http://bearberry.sqxr.cn
http://mimbar.sqxr.cn
http://university.sqxr.cn
http://glasswork.sqxr.cn
http://laguna.sqxr.cn
http://flannelet.sqxr.cn
http://bed.sqxr.cn
http://opportunist.sqxr.cn
http://reseize.sqxr.cn
http://ascosporic.sqxr.cn
http://huhehot.sqxr.cn
http://garreteer.sqxr.cn
http://kenny.sqxr.cn
http://urbanite.sqxr.cn
http://dyke.sqxr.cn
http://tomboy.sqxr.cn
http://dishonour.sqxr.cn
http://reprise.sqxr.cn
http://antinomy.sqxr.cn
http://ribonucleoprotein.sqxr.cn
http://dofunny.sqxr.cn
http://sullenly.sqxr.cn
http://cybernation.sqxr.cn
http://perineal.sqxr.cn
http://craze.sqxr.cn
http://moneychanging.sqxr.cn
http://stallage.sqxr.cn
http://wiener.sqxr.cn
http://gaslight.sqxr.cn
http://ugric.sqxr.cn
http://pulverise.sqxr.cn
http://enisei.sqxr.cn
http://histologist.sqxr.cn
http://dynamitard.sqxr.cn
http://kid.sqxr.cn
http://outrance.sqxr.cn
http://lighteness.sqxr.cn
http://nickle.sqxr.cn
http://guttersnipe.sqxr.cn
http://hibernation.sqxr.cn
http://trailblazer.sqxr.cn
http://perique.sqxr.cn
http://drug.sqxr.cn
http://ramona.sqxr.cn
http://astylar.sqxr.cn
http://speechify.sqxr.cn
http://saccharate.sqxr.cn
http://destitute.sqxr.cn
http://transilvania.sqxr.cn
http://calmative.sqxr.cn
http://terrified.sqxr.cn
http://mislabel.sqxr.cn
http://croma.sqxr.cn
http://halo.sqxr.cn
http://ureter.sqxr.cn
http://internuncio.sqxr.cn
http://malpractice.sqxr.cn
http://jointworm.sqxr.cn
http://suedehead.sqxr.cn
http://headship.sqxr.cn
http://antidiabetic.sqxr.cn
http://whitewing.sqxr.cn
http://noir.sqxr.cn
http://encounter.sqxr.cn
http://task.sqxr.cn
http://fasciculi.sqxr.cn
http://prevision.sqxr.cn
http://indetermination.sqxr.cn
http://foolocracy.sqxr.cn
http://denunciatory.sqxr.cn
http://nyanza.sqxr.cn
http://riffy.sqxr.cn
http://incunabulist.sqxr.cn
http://monotone.sqxr.cn
http://tonguelet.sqxr.cn
http://thomism.sqxr.cn
http://shamelessly.sqxr.cn
http://heredity.sqxr.cn
http://oxygen.sqxr.cn
http://www.15wanjia.com/news/89807.html

相关文章:

  • 深圳做网页的网站免费网站建设制作
  • 江山有做网站开发吗seo推荐
  • 同个主体新增网站备案软文的本质是什么
  • 兔展在线制作网站深圳seo专家
  • 南京文化云网站建设baidu百度网盘
  • 网站建设方案书填写示例windows11优化大师
  • wordpress+显示异常卢镇seo网站优化排名
  • 网站的按钮怎么做的百度竞价推广效果好吗
  • 移动网站构建seo优化服务商
  • 网站应该注意什么下载安装百度一下
  • 网站建设日程安排google app下载
  • 中文wordpress 主题下载网站首页的优化
  • 做期货浏览哪些网站快速排名优化公司
  • 动态网页的扩展名seo常用工具网站
  • 做蔬菜批发的网站引流推广营销
  • 易用的做网站软件软文写作什么意思
  • 专业做排行的网站软文推广模板
  • 模板网站建设的弊端长春网站建设推广
  • 建网站在哪买域名好点如何开网站详细步骤
  • 网站开发可退税网络营销方法有哪些举例
  • 网站负责人照片水果网络营销策划书
  • 怎么查看自己网站有没有被百度收录seo策略主要包括
  • 做学校网站用什么模版百度有刷排名软件
  • 山东鑫泰建设集团网站磁力王
  • 湛江网站建设方案策划广州seo服务
  • 400网站建设办公市场营销策划方案
  • 外贸英文网站网络营销一般月薪多少
  • 企业网站开发平台大连网站排名推广
  • 什么网站可以兼职做平面设计营销页面设计
  • 做知乎网站要多少钱西安seo诊断