网站建设优点,河北邯郸有什么好玩的地方,邯郸资讯,企业网站建设专业精准丨 鸣远科技目录
一、效果图
二、qtDesigner
三、ui文件如下#xff1a;
四、代码 一、效果图 二、qtDesigner
原理是利用属性动画来控制QFrame的minimumWidth属性。
①先拖出相应的控件 ②布局一下 ③填上一些样式 相关QSS
background-color: rgb(238, 242, 255);
border:2px sol…目录
一、效果图
二、qtDesigner
三、ui文件如下
四、代码 一、效果图 二、qtDesigner
原理是利用属性动画来控制QFrame的minimumWidth属性。
①先拖出相应的控件 ②布局一下 ③填上一些样式 相关QSS
background-color: rgb(238, 242, 255);
border:2px solid rgb(255, 255, 255);
border-radius:15px
QFrame{
background-color: qradialgradient(cx:0, cy:0, radius:1, fx:0.1, fy:0.1, stop:0 rgb(243, 175, 189), stop:1 rgb(155, 118, 218));
border-top-left-radius:30px;
border-top-right-radius:0px;
border-bottom-right-radius:0px;
border-bottom-left-radius:30px;
}
三、ui文件如下
?xml version1.0 encodingUTF-8?
ui version4.0classForm/classwidget classQWidget nameFormproperty namegeometryrectx0/xy0/ywidth400/widthheight300/height/rect/propertyproperty namewindowTitlestringForm/string/propertylayout classQVBoxLayout nameverticalLayoutitemwidget classQPushButton namepushButtonproperty nametextstringPushButton/string/property/widget/itemitemwidget classQFrame nameframeproperty nameframeShapeenumQFrame::StyledPanel/enum/propertyproperty nameframeShadowenumQFrame::Raised/enum/propertylayout classQHBoxLayout namehorizontalLayoutitemwidget classQSplitter namesplitterproperty nameorientationenumQt::Horizontal/enum/propertywidget classQLabel namelabelproperty namestyleSheetstring notrtruebackground-color: rgb(238, 242, 255);
border:2px solid rgb(255, 255, 255);
border-radius:15px/string/propertyproperty nametextstringTextLabel/string/property/widgetwidget classQLabel namelabel_2property namestyleSheetstring notrtruebackground-color: rgb(238, 242, 255);
border:2px solid rgb(255, 255, 255);
border-radius:15px/string/propertyproperty nametextstringTextLabel/string/property/widget/widget/itemitemwidget classQFrame nameframe_2property namemaximumSizesizewidth0/widthheight16777215/height/size/propertyproperty namestyleSheetstring notrtrueQFrame{
background-color: qradialgradient(cx:0, cy:0, radius:1, fx:0.1, fy:0.1, stop:0 rgb(243, 175, 189), stop:1 rgb(155, 118, 218));
border-top-left-radius:30px;
border-top-right-radius:0px;
border-bottom-right-radius:0px;
border-bottom-left-radius:30px;
}/string/propertyproperty nameframeShapeenumQFrame::StyledPanel/enum/propertyproperty nameframeShadowenumQFrame::Raised/enum/property/widget/item/layout/widget/item/layout/widgetresources/connections/
/ui四、代码
使用uic工具将ui文件转成py文件
import sysfrom PySide6.QtCore import QPropertyAnimation, QEasingCurve, QParallelAnimationGroup
from PySide6.QtWidgets import *from zzz.ui_home_03 import Ui_Form# 继承UI类
class MainWindow(QWidget, Ui_Form):def __init__(self, parentNone):super(MainWindow, self).__init__(parent)self.setupUi(self)self.pushButton.clicked.connect(self.settingBox)def settingBox(self):widthRightBox self.frame_2.width()maxExtend 100standard 0if widthRightBox 0:widthExtended maxExtendelse:widthExtended standard# 创建属性动画self.right_box QPropertyAnimation(self.frame_2, bminimumWidth)self.right_box.setDuration(500)self.right_box.setStartValue(widthRightBox)self.right_box.setEndValue(widthExtended)self.right_box.setEasingCurve(QEasingCurve.InOutQuart)self.right_box.start()# 动画组 如果是多个动画同时执行则创建动画组。# self.group QParallelAnimationGroup()# self.group.addAnimation(self.right_box)# self.group.start()if __name__ __main__:app QApplication()window MainWindow()window.show()sys.exit(app.exec())