32.QT绘图
- widget.h
#ifndef WIDGET_H
#define WIDGET_H #include <QWidget>
#include <QPainter>
#include <QPen>
#include <QEvent> namespace Ui {
class Widget;
} class Widget : public QWidget
{
Q_OBJECT public:
explicit Widget(QWidget *parent = );
~Widget();
20 void paintEvent(QPaintEvent *e);
21 QPainter *painter;
private:
Ui::Widget *ui;
}; #endif // WIDGET_H - widget.cpp
#include "widget.h"
#include "ui_widget.h" Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
setGeometry(,,,);
} Widget::~Widget()
{
delete ui;
} void Widget::paintEvent(QPaintEvent *e)
{
painter = new QPainter;
painter->begin(this);
painter->setPen(QPen(Qt::blue,,Qt::DashDotLine)); //画刷
painter->setBrush(QBrush(Qt::red,Qt::SolidPattern));
//画矩形
//painter->drawRect(20,20,180,180);
//画椭圆
//painter->drawEllipse(20,20,190,160);
//画点
//painter->drawPoint(100,100);
//画曲线
// painter->drawArc(20,20,210,160,500,1000); /*
case Line: //直线
p.drawLine(rect.topLeft(),rect.bottomRight()); break;
case Rectangle: //长方形
p.drawRect(rect); break;
case RoundRect: //圆角方形
p.drawRoundRect(rect); break;
case Ellipse: //椭圆形
p.drawEllipse(rect); break;
case Polygon: //多边形
p.drawPolygon(points,4); break;
case Polyline: //多边线
p.drawPolyline(points,4); break;
case Points: //点
p.drawPoints(points,4); break;
case Arc: //弧
p.drawArc(rect,startAngle,spanAngle); break;
case Path: //路径
p.drawPath(path); break;
case Text: //文字
p.drawText(rect,Qt::AlignCenter,tr("Hello Qt!")); break;
case Pixmap: //图片
p.drawPixmap(150,150,QPixmap("butterfly.png")); break;
default: break; painter->drawLine(QPoint(30,30),QPoint(60,180));
painter->drawText(this->rect(),Qt::AlignCenter,tr("Hello Qthello haihua!"));
painter->drawPixmap(150,150,QPixmap("1.png"));
*/ //画线
//painter->drawLine(QPoint(30,30),QPoint(60,180));
//painter->drawText(this->rect(),Qt::AlignCenter,tr("Hello"));
//画图
painter->drawPixmap(,,QPixmap("1.png"));
painter->end();
}
32.QT绘图的更多相关文章
- Qt绘图
Qt绘图的设置 QPainter::Antialiasing // 反锯齿 QPainter::TextAntialiasing // 文字反锯齿 QPainter::SmoothPixmapTran ...
- Qt绘图之QGraphicsScene QGraphicsView QGraphicsItem详解
Graphics View提供了一个界面,它既可以管理大数量的定制2D graphical items,又可与它们交互,有一个view widget可以把这些项绘制出来,并支持旋转与缩放.这个柜架也包 ...
- 简单的QT绘图程序(把全部的点都记录下来,然后在paintEvent里使用drawLine函数进行绘制,貌似效率很低。。。)
当初在学MFC时,最经典的入门实例就是绘图程序,其作用相当于Console Application 下的Hello World了吧. 如今入手QT,不免怀旧,于是也写了一个绘图程序,虽然简单,却也是入 ...
- 界面编程之QT绘图和绘图设备20180728
/*******************************************************************************************/ 一.绘图 整 ...
- Qt 绘图与动画系统
Qt 提供了内置的绘图系统以及独立的QtOpenGL模块提供对OpenGL的支持.Qt提供了基于状态机的QPainter系统和面向对象的Graphics View系统. QPainter 基于状态机的 ...
- Qt——绘图
1.涉及类 QPainter QPaintEngine QPaintDevice 作为绘图的使用者,只需要关注 QPainter 和 QPaintDevice 2.QPainter 使用 QPain ...
- Qt 绘图(QBitmap,QPixmap,QImage,QPicture)
QPainter绘图绘图设备(QPixmap,QImage,QBitmap,QPicture) 重写绘图事件,虚函数 如果窗口绘图,必须放在绘图事件里实现 绘图事件内部自动调用,窗口需要重绘的时候,状 ...
- Qt绘图学习(1)
paintEvent()被调用的时机;1.当窗口第一次被show()的时候,Qt程序会自动产生一个绘图事件,调用绘图事件:2.重新调整窗口部件大小的时候,系统也会产生一个绘制事件.3.当窗口部件被其他 ...
- Qt绘图浅析与实例
1. Qt5位置相关函数 Q提供了很多关于获取窗体位置及显示区域大小的函数,如x().y()和pos().rect().size().geometry()等,统称为"位置相关函数" ...
随机推荐
- SVG剪裁路径和遮罩jQuery幻灯片
SVG剪裁路径和遮罩jQuery幻灯片是一款基于SVG clipPath和mask遮罩元素实现的网站动画幻灯片代码特效. 在线演示本地下载
- 使用Scanner获取键盘输入 (转)
原文地址:https://www.cnblogs.com/SzBlog/p/5404335.html 后面有改动 使用Scanner类可以很方便地便获取用户的键盘输入,Scanner是一个基于正则表达 ...
- python os 模块常用操作
python 2.7 os 常用操作 官方document链接 文件和目录 os.access(path, mode) 读写权限测试 应用: try: fp = open("myfile&q ...
- 【Oracle】SCOPE=MEMORY|SPFILE|BOTH
SCOPE=MEMORY|SPFILE|BOTH 指示了修改参数时的“作用域”: SCOPE=MEMORY :只在实例中修改,重启数据库后此次修改失效. SCOPE=SPFILE :只修改SPFILE ...
- redis启动出错 Creating Server TCP listening socket 127.0.0.1:6379: bind: No error解决办法
windows下安装Redis第一次启动报错: [2368] 21 Apr 02:57:05.611 # Creating Server TCP listening socket 127.0.0.1: ...
- FFmpeg avcodec_send_packet压缩包函数
首先看一下FFmpeg关于该packet函数的注释: int avcodec_send_packet ( AVCodecContext * avctx, const AVPacket * ...
- 小白学习Spark系列四:RDD踩坑总结(scala+spark2.1 sql常用方法)
初次尝试用 Spark+scala 完成项目的重构,由于两者之前都没接触过,所以边学边用的过程大多艰难.首先面临的是如何快速上手,然后是代码调优.性能调优.本章主要记录自己在项目中遇到的问题以及解决方 ...
- Python笔记5----集合set
1.集合的概念:无序不重复 分为可变集合(set())和不可变集合(frozenset)两种 2.创建集合 aset=set('hello') >>aset={'h','e','l','o ...
- Codeforces Round #468 (Div. 2, based on Technocup 2018 Final Round)A. Friends Meeting
Two friends are on the coordinate axis Ox in points with integer coordinates. One of them is in the ...
- Asp.Net IHttpHandler介绍
ASP.NET响应Http请求时常用的两个处理接口是IHttpHandler和IHttpModule. 一般的,IHttpHandler用来处理一类特定的请求,比如对每个*.asp, *.aspx文件 ...