Results 1 to 2 of 2

Thread: QToolBar not resizing

  1. #1
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QToolBar not resizing

    Hi all,
    I have a QMainWindow with a vertical ToolBar on the left.
    I have several toolButtons on ToolBar. On one of the toolButton
    there is a popupmenu, which pops up when I click.

    The problem:
    The pop up menu inside the toolbutton has many entires with names.
    The length of the names are small as well as long.
    Now suppose, I have these names in popupmenu:
    1)"ABC"
    2) "HELLOQTCENTRE"
    3) "MG"
    4) "SEEYOULATER"
    5) "CONSTANTTOUCH"

    Now initially I set "ABC" as my popup menuItem. Hence initially
    "ABC" is selected.
    Then I select "HELLOQTCENTRE", the toolBar is expanded(horizontally), again
    I select "MG", the toolbar doesnt shrink back(horizontally). It occupies the
    same space as before i.e the space for "HELLOQTCENTRE"...

    I tried setting the sizepolicy but still it doesnt work.

    I want the ToolBar to get resized depending on popup menuItem selected. Please help
    Hope I'm clear.
    Thanks

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QToolBar not resizing

    Try first with QToolBar::layout()->setSizeConstraint(QLayout::MinimumSize), although I doubt it will work.

    Another solution is to force a resize after you select a new item.
    When you select a new item:
    Qt Code:
    1. toolbar->resize(toolbar->minimumWidth(), toolbar->sizeHint().height());
    To copy to clipboard, switch view to plain text mode 


    Regards

  3. The following 2 users say thank you to marcel for this useful post:

    suspiria (31st December 2011), vermarajeev (20th July 2007)

Similar Threads

  1. Various icon sizes for QToolButtons on QToolbar
    By Erlendhg in forum Qt Programming
    Replies: 4
    Last Post: 30th June 2007, 18:35
  2. QMdiSubWindow resizing in 4.3
    By kalpa in forum Qt Programming
    Replies: 0
    Last Post: 4th June 2007, 13:39
  3. How Do I Float a QToolBar?
    By dvmorris in forum Qt Programming
    Replies: 7
    Last Post: 29th April 2007, 19:01
  4. QToolBar in a new UI form?
    By gfunk in forum Qt Tools
    Replies: 7
    Last Post: 2nd June 2006, 11:19
  5. Insert separate QToolBar into QMainWindow
    By YuriyRusinov in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 10:37

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
  •  
Qt is a trademark of The Qt Company.