We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
发现在 components.widgets.menu SubMenuItemWidget类的 paintEvent方法中 self.width()每次调用会增加20, 添加self.setFixedWidth(self.width())可以解决bug
components.widgets.menu SubMenuItemWidget
paintEvent
self.width()
self.setFixedWidth(self.width())
Windows11
3.10.7
PyQt5.15.10
1.5.2
self.commandBar.addWidget(self.createDropDownButton()) def createSubMenu(self): sub_menu = RoundMenu("Font style", self) sub_menu.setIcon(QIcon(':/res/font_style.png')) sub_menu.setMaxVisibleItems(10) sub_menu.addActions([ Action(FontStyles[i], triggered=lambda _: self.fontStyle(i)) for i in range(len(FontStyles)) ]) return sub_menu def createDropDownButton(self): button = DropDownToolButton(FluentIcon.FONT, self) button.setFixedHeight(20) menu = RoundMenu(parent=self) menu.addMenu(self.createSubMenu()) button.setMenu(menu) return button
The text was updated successfully, but these errors were encountered:
是由与RoundMenu::adjustSize的self.viewport().adjustSize()这一句导致的。
看了一下qt源码,adjustSize这个语句做了以下几件事:
r=childrenRect()
QSize(r.width()+2*r.x(), r.height + 2*r.y())
不知道为什么,在菜单显示之后,childrenRect的x始终是36,所以viewport每次会增大72,而内部控件会在viewport增大后自动扩大,接下来就是重复套娃。 没有很好的解决方案,如果确定RoundMenu不允许内部控件动态改变大小,这里可以替换成
r = self.viewport().childrenRect() self.viewport().resize(self.viewport().width(), r.height() + 2 * r.y())
现在的RoundMenu其实也无法容纳动态的Widget,因为QListsWidgetItem的sizeHint是在插入时设置的,而RoundMenu依靠item的sizeHint宽度来计算自己的宽度,如果要支持动态宽度的Widget,可能需要继承QListsWidgetItem重写一个item
Sorry, something went wrong.
修复了多次点击二级菜单后菜单位置异常 (zhiyiYo#792, zhiyiYo#844)
4d6cd11
No branches or pull requests
What happened?
发现在
components.widgets.menu SubMenuItemWidget
类的paintEvent
方法中self.width()
每次调用会增加20, 添加self.setFixedWidth(self.width())
可以解决bugOperation System
Windows11
Python Version
3.10.7
PyQt/PySide Version
PyQt5.15.10
PyQt/PySide-Fluent-Widgets Version
1.5.2
How to Reproduce?
Minimum code
The text was updated successfully, but these errors were encountered: