Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

why setVisibe not work?



  • why setVisibe not work?
    i want to dynamically show or hide a QCombo in a Toolbar.
    but setVisibe(false); not work.
    while setEnabled() do work.



  • QAction * QToolBar::addWidget(QWidget * widget)
    Adds the given widget to the toolbar as the toolbar's last item.

    The toolbar takes ownership of widget.

    If you add a QToolButton with this method, the toolbar's Qt::ToolButtonStyle will not be respected.

    Note: You should use QAction::setVisible() to change the visibility of the widget. Using QWidget::setVisible(), QWidget::show() and QWidget::hide() does not work.



  • but it's a QComboBox in the QToolbar....how can i use QAction??


  • Lifetime Qt Champion

    Hi,

    Look again at the function signature: you get a QAction as a result of addWidget.


Log in to reply