You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# coding:utf-8importsysfromPyQt5.QtCoreimportQtfromPyQt5.QtWidgetsimportQApplication, QWidget, QHBoxLayoutfromqfluentwidgetsimportInfoBarIcon, InfoBar, PushButton, InfoBarPositionclassDemo(QWidget):
def__init__(self):
super().__init__()
self.hBoxLayout=QHBoxLayout(self)
self.button1=PushButton('Information', self)
self.button1.clicked.connect(self.createInfoInfoBar)
self.hBoxLayout.addWidget(self.button1)
self.hBoxLayout.setContentsMargins(30, 0, 30, 0)
self.resize(700, 700)
defcreateInfoInfoBar(self):
content="My name is kira yoshikake, 33 years old. Living in the villa area northeast of duwangting, unmarried. I work in Guiyou chain store. Every day I have to work overtime until 8 p.m. to go home. I don't smoke. The wine is only for a taste. Sleep at 11 p.m. for 8 hours a day. Before I go to bed, I must drink a cup of warm milk, then do 20 minutes of soft exercise, get on the bed, and immediately fall asleep. Never leave fatigue and stress until the next day. Doctors say I'm normal."w=InfoBar(
icon=InfoBarIcon.INFORMATION,
title='Title',
content=content,
orient=Qt.Vertical, # vertical layoutisClosable=True,
position=InfoBarPosition.TOP_RIGHT,
duration=2000,
parent=self
)
w.addWidget(PushButton('Action'))
w.show()
defcloseEvent(self, e) ->None:
self.hide()
e.ignore()
if__name__=='__main__':
# enable dpi scaleQApplication.setHighDpiScaleFactorRoundingPolicy(
Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
app=QApplication(sys.argv)
w=Demo()
w.show()
app.exec_()
The text was updated successfully, but these errors were encountered:
What happened?
在给主程序增加托盘图标时,重写了closeEvent,隐藏主界面并忽略关闭事件。但在显示消息条时点击关闭按钮,过会儿程序会退出。
问题点:
解决办法:
Operation System
WIn11 23H2
Python Version
3.11.1
PyQt/PySide Version
5.15.10
PyQt/PySide-Fluent-Widgets Version
1.5.7
How to Reproduce?
使用example里的gallery程序,在MainWIndow重写closeEvent:
运行gallery,在消息页面点击显示一条消息条,在消息条消失前点击窗口关闭按钮,等待几秒消息条finished,然后程序退出了,exit code 0.
Minimum code
The text was updated successfully, but these errors were encountered: