Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以更改 QMenu 撕下子控件的位置,将其放在右侧?
我想这样做:
我尝试用这个改变样式表:
QMenu::tearoff { background-color:red; subcontrol-position: right bottom; }
但没有成功。有人有想法吗?我想避免完全重新实现自定义 QMenu。
经过反复试验,我找到了一个非常简单的解决方案。
您只需为 设置一个新的布局QMenu,它因此包含 a QMenu(您将填充的那个),并且在右侧(或您想要的任何地方),只需插入 aQPushButton即可作为撕下。单击该按钮时,您可以使用 显示另一个菜单(包含相同的操作)show()。
QMenu
QPushButton
show()