2、在QDialog窗体中显示QWidget部件
【效果图】
【资源】
【代码】
import sysfrom PyQt5.QtCore import *from PyQt5.QtGui import *from PyQt5.QtWidgets import *class StockDialog(QWidget):def __init__(self, parent=None):
super(StockDialog, self).__init__(parent)
self.setWindowTitle("利用QPainter绘制各种图形")
mainSplitter = QSplitter(Qt.Horizontal)
mainSplitter.setOpaqueResize(True)
frame = QFrame(mainSplitter)
mainLayout = QGridLayout(frame)#mainLayout.setMargin(10)
mainLayout.setSpacing(6)
label1=QLabel("形状:")
label2=QLabel("画笔线宽:")
label3=QLabel("画笔颜色:")
label4=QLabel("画笔风格:")
label5=QLabel("画笔顶端:")
label6=QLabel("画笔连接点:")
label7=QLabel("画刷风格:")
label8=QLabel("画刷颜色:")
self.shapeComboBox = QComboBox()
self.shapeComboBox.addItem("Line", "Line")
self.shapeComboBox.addItem("Rectangle", "Rectangle")
self.shapeComboBox.addItem('Rounded Rectangle','Rounded Rectangle')
self.shapeComboBox.addItem('Ellipse','Ellipse')
self.shapeComboBox.addItem('Pie','Pie')
self.shapeComboBox.addItem('Chord','Chord')
self.shapeComboBox.addItem('Path','Path')
self.shapeComboBox.addItem('Polygon','Polygon')
self.shapeComboBox.addItem('Polyline','Polyline')
self.shapeComboBox.addItem('Arc','Arc')
self.shapeComboBox.addItem('Points','Points')
self.shapeComboBox.addItem('Text','Text')
self.shapeComboBox.addItem('Pixmap','Pixmap')
self.widthSpinBox = QSpinBox()
self.widthSpinBox.setRange(0,20)
self.penColorFrame = QFrame()
self.penColorFrame.setAutoFillBackground(True)
self.penColorFrame.setPalette(QPalette(Qt.blue))
self.penColorPushButton = QPushButton("更改")
self.penStyleComboBox = QComboBox()
self.penStyleComboBox.addItem("Solid",Qt.SolidLine)
self.penStyleComboBox.addItem('Dash',Qt.DashLine)
self.penStyleComboBox.addItem('Dot',Qt.DotLine)
self.penStyleComboBox.addItem('Dash Dot',Qt.DashDotLine)
self.penStyleComboBox.addItem('Dash Dot Dot',Qt.DashDotDotLine)
self.penStyleComboBox.addItem('None',Qt.NoPen)
self.penCapComboBox = QComboBox()
self.penCapComboBox.addItem("Flat",Qt.FlatCap)
self.penCapComboBox.addItem('Square', Qt.SquareCap)
self.penCapComboBox.addItem('Round', Qt.RoundCap)
self.penJoinComboBox = QComboBox()
self.penJoinComboBox.addItem("Miter",Qt.MiterJoin)
self.penJoinComboBox.addItem('Bebel', Qt.BevelJoin)
self.penJoinComboBox.addItem('Round', Qt.RoundJoin)
self.brushStyleComboBox = QComboBox()
self.brushStyleComboBox.addItem("Linear Gradient",Qt.LinearGradientPattern)
self.brushStyleComboBox.addItem('Radial Gradient', Qt.RadialGradientPattern)
self.brushStyleComboBox.addItem('Conical Gradient', Qt.ConicalGradientPattern)
self.brushStyleComboBox.addItem('Texture', Qt.TexturePattern)
self.brushStyleComboBox.addItem('Solid', Qt.SolidPattern)
self.brushStyleComboBox.addItem('Horizontal', Qt.HorPattern)
self.brushStyleComboBox.addItem('Vertical', Qt.VerPattern)
self.brushStyleComboBox.addItem('Cross', Qt.CrossPattern)
self.brushStyleComboBox.addItem('Backward Diagonal', Qt.BDiagPattern)
self.brushStyleComboBox.addItem('Forward Diagonal', Qt.FDiagPattern)
self.brushStyleComboBox.addItem('Diagonal Cross', Qt.DiagCrossPattern)
self.brushStyleComboBox.addItem('Dense 1', Qt.Dense1Pattern)
self.brushStyleComboBox.addItem('Dense 2', Qt.Dense2Pattern)
self.brushStyleComboBox.addItem('Dense 3', Qt.Dense3Pattern)
self.brushStyleComboBox.addItem('Dense 4', Qt.Dense4Pattern)
self.brushStyleComboBox.addItem('Dense 5', Qt.Dense5Pattern)
self.brushStyleComboBox.addItem('Dense 6', Qt.Dense6Pattern)
self.brushStyleComboBox.addItem('Dense 7', Qt.Dense7Pattern)
推荐阅读
- erp系统打电话话术,erp电话营销招聘
- 西瓜视频选什么格式,西瓜视频格式要求
- mysql数据库跟jdk,java与mysql数据库连接
- 单机美甲游戏,美甲游戏大全免费版
- 怎么安装mysql57 怎么安装mysql55
- 视频号申请后不使用怎么办,视频号用申请吗
- 家里怎么用千兆路由器,家庭用千兆无线路由器
- 桌面游戏英语字母如何玩,桌面游戏英文怎么写
- python循环的函数 python循环函数不换行