一般的情况下有工具栏的都用QMainWindow作为基类,但是我不想用QMainWindos做基类,我只是想使用其中的QToolButton和StatusBar,所以用QWidget做基类
QToolButton添加到ToolBar后它本身的一些属性就不能用了,我向实现有外围设备插入后在工具栏显示图标,设备移除后图标也相应的移除,如果哦是用QAction还好弄,只要用QAction的函数
void QToolBar::addAction ( QAction * action )
This is an overloaded function.
Appends the action action to the toolbar's list of actions.
这个函数实现在工具栏中添加动作QAction,当移除时就可以用
void QWidget::removeAction ( QAction * action )
Removes the action action from this widget's list of actions.
See also insertAction(), actions(), and insertAction().
这个是在工具栏的一个点击一次只可以有一个动作的情况,我想实现的是在工具栏的按钮上可以再加上下拉菜单,比如插入个USB设备,他的下拉菜单有移除USB设备,打开USB设备,这样的情况下用QAction就不合适 ,在QAction中有设置菜单的函数,但是我用那个很不好用,后来换上了QToolButton,QToolButton的的setPopupMode要设置成
QToolButton::InstantPopup,否则也不好用,它的菜单动作不能马上调出来,由于想移除图标&#x