这行得通..。
QToolButton * toolbutton = new QToolButton(this);
//hide before addWidget
toolbutton->hide();
addWidget(toolbutton);
但这不是
QToolButton * toolbutton = new QToolButton(this)
addWidget(toolbutton);
//hide after addWidget
toolbutton->hide();
有没有其他方法可以让我在QToolButton添加到QToolBar后真正隐藏起来?在运行时我需要这样做。
发布于 2012-02-18 13:12:07
一种替代方法是添加QAction而不是小部件,然后隐藏QAction。我已经尝试过了,它可以与QAction::setVisible(false)一起工作。
如果知道小部件在QToolBar中的位置,还可以执行类似QToolBar::actions().at(3)->setVisible(false);的操作。
发布于 2012-02-19 01:39:20
QAction * QToolBar::addWidget ( QWidget * widget )
您应该隐藏返回的QAction
发布于 2012-02-18 13:22:47
toolbar->actions().at(0)->setVisible(false);
https://stackoverflow.com/questions/9338640
复制相似问题