from qfluentwidgets import RoundMenu,Action
from PyQt6.QtWidgets import QApplication
import sys
app = QApplication(sys.argv)
my_Menu=RoundMenu()
actions=[Action("action{}".format(i)) for i in range(10)]
for action in actions:
my_Menu.addAction(action)
my_Menu.addSeparator()
my_Menu.show()
for action in actions:
my_Menu.removeAction(action)
sys.exit(app.exec())
Minimum code
from qfluentwidgets import RoundMenu,Action
from PyQt6.QtWidgets import QApplication
import sys
app = QApplication(sys.argv)
my_Menu=RoundMenu()
actions=[Action("action{}".format(i)) for i in range(10)]
for action in actions:
my_Menu.addAction(action)
my_Menu.addSeparator()
my_Menu.show()
for action in actions:
my_Menu.removeAction(action)
sys.exit(app.exec())
What happened?
在RoundMenu的删除Action的代码中
self.view.takeitem(index)
中的index与_actions
中的index一致。如果此时菜单中包含分割线(Separator), 则分割线也是一个item,也占用一个index位置。这将导致删除某些Action中实际上在view中删除的是分割线而不是action对应的item。Operation System
Windows 11
Python Version
3.11.5
PyQt/PySide Version
PyQt6
PyQt/PySide-Fluent-Widgets Version
1.2.0
How to Reproduce?
运行以下代码将会发现action5-9还出现在菜单中:
Minimum code