【发布时间】:2011-12-11 04:43:24
【问题描述】:
为什么这不起作用?它应该是这样工作的:当单击“文件”时,工具栏(不是菜单栏)显示在菜单栏的正下方,上面有不同的按钮,可以在“文件”菜单中找到,当单击“编辑”时隐藏“文件”工具栏,显示“编辑”工具栏。
menubar = new MyMenuBar(this);//this is a menubar with "file" and "edit"
menubar->setGeometry(0,0,1100,30);
ftoolbar = new MyFileToolBar(this); // this is a toolbar with buttons that would be
// found in a "file" menu
ftoolbar->setGeometry(0,30,1100,40);
ftoolbar->hide();
etoolbar = new MyEditToolBar(this); // this is a toolbar with buttons that would be
//found in an "edit" menu
etoolbar->setGeometry(0,30,1100,40);
etoolbar->hide();
//here down does not work
connect(menubar->File, SIGNAL(aboutToShow()), ftoolbar, SLOT(show()));
connect(menubar->File, SIGNAL(aboutToHide()), ftoolbar, SLOT(hide()));
connect(menubar->Edit, SIGNAL(aboutToShow()), etoolbar, SLOT(show()));
connect(menubar->Edit, SIGNAL(aboutToHide()), etoolbar, SLOT(hide()));
文件 编辑
【问题讨论】:
-
没关系!我修复了它,但由于某种原因,stacko 不允许我回答我的问题......所以不要回答。我用 aboutToShow() 替换了trigger(QAction*)
-
我有兴趣查看菜单栏内工具栏的屏幕截图。
-
@Sosukodo:在菜单栏下方(在其正常位置)。不在里面。
-
这听起来很有趣,但我无法理解它。你知道有这样的应用程序吗?我有 Windows、Mac、Android 和 Linux(Mint) 设备,所以你能指点我的任何东西都会很棒!
-
顺便说一句,这些按钮在工具栏中,但在 Ubuntu 上显示不佳
标签: c++ qt custom-controls toolbar menubar