当前位置:网站首页>QT brushes and brushes
QT brushes and brushes
2022-06-13 04:55:00 【qq_ thirty-nine million two hundred and eighty thousand seven h】
Qt Introduction to drawing system
Qt Provides a powerful 2D Drawing system , You can use the same API Drawing on screen and drawing equipment , It's mainly based on QPainter、QPaintDevice and QPaintEngine These three categories .
QPainter Used to perform drawing operations ; QPaintDevice Provide drawing equipment , It's an abstraction of two-dimensional space , have access to QPainter Draw on it ; QPaintEngine Some interfaces are provided , It can be used for QPainter Drawing on different devices .
stay Qt In the drawing system , from QPainter To complete the specific drawing operation .QPainter Generally in the redrawing event of a part (Paint Event) Processing function of paintEvent() Drawing in :
The first thing to do is to create QPainter object ; And then draw the graph ; Finally destroy QPainter object .
QPainter Usage mode
1.QPainter In the constructor ,parent Specify the drawing object ( equipment );QPainter Automatically call... In the constructor begin function , Indicates the beginning of the drawing , stay QPainter Call in the destructor end() Function ends drawing .
QRectF rectangle(10.0, 20.0, 80.0, 60.0);
int startAngle = 30 * 16;
int spanAngle = 120 * 16;
QPainter painter(this);
painter.drawArc(rectangle, startAngle, spanAngle);
2. When constructing , Do not specify... In the constructor parent( Drawing objects ); Display call begin(parent) Specify the drawing device .
At the end of the drawing , Display call end() function .
QRectF rectangle(10.0, 20.0, 80.0, 60.0);
int startAngle = 30 * 16;
int spanAngle = 120 * 16;
QPainter painter;
painter.begin(this); // Designated equipment
painter.drawArc(rectangle, startAngle, spanAngle);
painter.end();
Brushes and brushes
The brush specifies the style of the outline of the pattern
Brush specifies the fill pattern of the pattern
Brushes used
// Use the brush , Set brush style
QPen pen(Qt::red,6, Qt::DashDotLine, Qt::RoundCap, Qt::RoundJoin);
painter.setPen(pen);
painter.drawArc(rectangle, startAngle, spanAngle);
Use a brush
// Create a brush , Set the style of the brush
QBrush brush(QColor(0, 0, 255), Qt::Dense4Pattern);
// Use the brush
painter.setBrush(brush);
// Draw the ellipse
painter.drawEllipse(220, 20, 50, 50);
边栏推荐
- Advanced C - Section 2 - pointers
- Promise processing JS multithreads get the same processing result after all the results are obtained
- CMB written test graphical reasoning
- Explain the differences and usage scenarios between created and mounted
- 135. distribute candy
- Cesium:CesiumLab制作影像切片与切片加载
- [untitled]
- rainbow
- Section 7 - structures
- Vercel uses HTTP caching
猜你喜欢
PostgreSQL Guide: Insider exploration (Chapter 7 heap tuples and index only scanning) - Notes
Sampo Lock
Kaggle time series tutorial
PowerShell plus domain add computer module
Win8.1和Win10各自的優勢
Embedded hardware - read schematic
Section 5 - Operator details
[LeetCode]-二分查找
How to use redis
CMB written test graphical reasoning
随机推荐
String()和toString()方法得区别
Elliptic curve encryption
[leetcode]- binary search
PowerShell plus domain add computer module
[try to hack] upload labs (temporarily write to 12)
Internet people a few years ago vs Internet people today
MySQL8.0.13安装教程(有图)
Robot pose description and coordinate transformation
General communication protocol for industrial Internet
Explain the role of key attribute in V-for
用navicat将mysql数据转化为postgresql
小C的记事本
Draw a hammer
Basic syntax example for go
josephus problem
Chinese trumpet creeper
Mind mapping series - Database
Brick story
Go/golang connection to database
[JS solution] leedcode 200 Number of islands