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.
有人可以解释为什么这个语句什么都不做吗?
ui.menuBar->setCornerWidget(ui.menuHelp, Qt::TopRightCorner);
menuBar是一个QMenuBar并且menuHelp是QMenu
menuBar
QMenuBar
menuHelp
QMenu
我仍然将所有 QMenu 聚集在窗口的左侧
要将菜单添加到菜单栏的右侧,您应该QMenuBar使用以下方法添加一个包含所需菜单的新菜单作为右角小部件setCornerWidget:
setCornerWidget
QMenuBar *bar = new QMenuBar(ui->menuBar); QMenu *menuHelp = new QMenu("Help", bar); bar->addMenu(menuHelp); ui->menuBar->setCornerWidget(bar);