Qt 移除工具条后,再次添加不显示问题

当软件有很多工具条时,会有remove工具条的需求,后面需要时,再add进来。

那么,先执行removeToolBar(),再执行addToolBar(),工具条是不会显示出来的;

原因其实很简单,官方文档写的很清楚,remove时并并不是真的删除,只是隐藏了而已,再次add后,ToolBar依旧是隐藏状态,所以不显示

void QMainWindow::removeToolBar(QToolBar *toolbar)

Removes the toolbar from the main window layout and hides it. Note that the toolbar is not deleted.

同理,Qt 状态栏 添加/移除 QWidget 也是同样的道理,移除后只是隐藏,添加并不改变QWidget 的状态,需要手动调用show().

void QStatusBar::removeWidget(QWidget *widget)

Removes the specified widget from the status bar.
Note: This function does not delete the widget but hides it. To add the widget again, you must call both the addWidget() and show() functions.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值