Results 1 to 3 of 3

Thread: remove Widget from QToolBar?

  1. #1
    Join Date
    Jul 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Unhappy remove Widget from QToolBar?

    Hi to all!!!
    i want to know how can i remove widget from QToolbar!!!
    ex: ToolBar->addWidget(ComboBox);
    i want to remove this ComboBox without using clear function?
    please help me!!!
    Thanks to all of you !!!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: remove Widget from QToolBar?

    Haven't tried it but QWidget::removeAction() with the QAction pointer returned when you added the widget looks promising.

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: remove Widget from QToolBar?

    If you simply want to hide the combobox, you may use QAction::setVisible
    From the docs -
    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 tools bar'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.

Similar Threads

  1. how to add QToolbar on a widget inherited from QWidget
    By xiongxiongchuan in forum Qt Programming
    Replies: 2
    Last Post: 9th June 2010, 05:06
  2. Remove widget from a QList
    By Eos Pengwern in forum Newbie
    Replies: 4
    Last Post: 16th October 2009, 21:25
  3. Replies: 1
    Last Post: 21st February 2009, 14:59
  4. Remove Widget Border?
    By winston2020 in forum Qt Programming
    Replies: 5
    Last Post: 20th October 2008, 05:26
  5. How to remove widget added in runtime?
    By jiveaxe in forum Qt Programming
    Replies: 7
    Last Post: 2nd November 2007, 10:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.