当前位置:网站首页>PyQt5-绘制不同类型的直线
PyQt5-绘制不同类型的直线
2022-07-30 09:05:00 【獜洛橙】
效果如下:

代码如下:
'''
绘制不同类型的直线
'''
import sys,math
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import Qt
class DrawMultiLine(QWidget):
def __init__(self):
super(DrawMultiLine,self).__init__()
self.resize(300,300)
self.setWindowTitle('设置Pen的样式')
def paintEvent(self, event):
painter = QPainter()
painter.begin(self)
pen = QPen(Qt.red,3,Qt.SolidLine)
painter.setPen(pen)
painter.drawLine(20,40,250,40)
pen.setStyle(Qt.DashLine)
painter.setPen(pen)
painter.drawLine(20, 80, 250, 80)
pen.setStyle(Qt.DashDotDotLine)
painter.setPen(pen)
painter.drawLine(20, 120, 250, 120)
pen.setStyle(Qt.DotLine)
painter.setPen(pen)
painter.drawLine(20, 160, 250, 160)
pen.setStyle(Qt.DashDotDotLine)
painter.setPen(pen)
painter.drawLine(20, 200, 250, 200)
pen.setStyle(Qt.CustomDashLine)
pen.setDashPattern([1,10,5,8])
painter.setPen(pen)
painter.drawLine(20, 240, 250, 240)
size = self.size()
painter.end()
if __name__ == '__main__':
app = QApplication(sys.argv)
main = DrawMultiLine()
main.show()
sys.exit(app.exec_())边栏推荐
- leetcode 剑指 Offer 21. 调整数组顺序使奇数位于偶数前面
- 百度paddleocr检测训练
- 激活数据潜力 亚马逊云科技重塑云上存储“全家桶”
- 聊聊 MySQL 事务二阶段提交
- 新手必备!最全电路基础知识讲解
- leetcode 剑指 Offer 25. 合并两个排序的链表
- ACL 2022 | Introduce angular margin to construct comparative learning objectives and enhance text semantic discrimination ability
- 342 · 山谷序列
- How to avoid CMDB becoming a data island?
- 无法定位程序输入点ucrtbase.abort于动态链接库api-ms-win-crt-runtime-|1-1-0.dll上
猜你喜欢
随机推荐
The difference between DDR, GDDR, QDR
Scala
激活数据潜力 亚马逊云科技重塑云上存储“全家桶”
ThreadLocal内存泄漏是伪命题?
功能测试、UI自动化测试(web自动化测试)、接口自动化测试
Is R&D moving to FAE (Field Application Engineer), is it moving away from technology?Is there a future?
Excel xlsx file not supported两种解决办法【杭州多测师】【杭州多测师_王sir】
宝塔搭建DM企业建站系统源码实测
leetcode 剑指 Offer 42. 连续子数组的最大和
Integral Special Notes - Definition of Integral
Concise Notes on Integrals - Types of Curve Integrals of the Second Kind
pnpm简介
LeetCode二叉树系列——94.二叉树的中序遍历
MySQL【运算符】
虚幻引擎图文笔记:could not be compiled. Try rebuilding from source manually.问题的解决
Network/Information Security Top Journal and Related Journals Conference
leetcode 剑指 Offer 10- II. 青蛙跳台阶问题
qsort 函数的使用及其模拟实现
获取显示器数据
Circuit analysis: constant current source circuit composed of op amp and triode









