in the use of pyqt5 at the beginning of the function is relatively less, did not use the menu function, and then more, need to use the menu, otherwise the layout is quite messy, but in the menuBar () to add menus and submenus, how to remove the submenu chart area, looking for a long time did not find a way.
here is the code:
class MyMainWindow(QMainWindow):
def __init__(self):
super(HRMainWindow, self).__init__()
-sharp
main_menu = self.menuBar()
-sharp
system_menu = main_menu.addMenu("")
-sharp
button = QAction("", self)
-sharp
button.setIconVisibleInMenu(False)
-sharp
system_menu.addAction(button)
effect:
ideal goal:
the red box in the figure is removed and does not occupy a position.
does anyone know? Solve the problem.