Results 1 to 5 of 5

Thread: Getting the Menubar and Toolbar on the same row in QT

  1. #1
    Join Date
    Feb 2012
    Posts
    4
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Getting the Menubar and Toolbar on the same row in QT

    Hi,

    I need to have the Toolbar on the same row as the Menubar to capitilize on the Vertical space in my application. I want the menubar to occupy 1/3 of the screen followed by the Toolbar. I tried setting the width of the menu via the SetWidth() fn for the menu, but it still continues to occupy the entire horizontal space. I then made a frame of 1/3rd width and added the menubar in this frame, then added the toolbar at the side, problem with this approach is that the application allows customizable menu's. So when we add a new menu to the menubar I would like the Toolbar to automatically shrink in size, I would appreciate any ideas on how I can achieve this.

    Regards,
    Sangeeta.

  2. #2
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Getting the Menubar and Toolbar on the same row in QT

    Hi,

    You could put the menubar inside the QToolbar using yourtoolbar->insertWidget( ).

    Regards,
    Marc

  3. The following user says thank you to marcvanriet for this useful post:

    sangs_shenoy (21st February 2012)

  4. #3
    Join Date
    Feb 2012
    Posts
    4
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Getting the Menubar and Toolbar on the same row in QT

    Thanks Marc for your reply. I guess I skipped mentioining that I want the menubar to be fixed and not dockable, whereas the actual toolbar should be dockable. So that would mean making two toolbars one holding the menu and the other for the toolbar? Also when I increase the width of the menu dynamically in the application, how do I trigger the other toolbar to shrink in size?

    I dont need the menubar within the Toolbar essentially, is there some way of specifying a width for the QMenubar and then docking the Toolbar after this width?

    Regards,
    Sangeeta.

  5. #4
    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: Getting the Menubar and Toolbar on the same row in QT

    I dont need the menubar within the Toolbar essentially, is there some way of specifying a width for the QMenubar and then docking the Toolbar after this width?
    In a main window there iss vertical space for an (optional) menu bar and underneath that vertical space for a tool bar or bars. So yes, you do want your menu inside a tool bar. You can QToolBar::setFloatable() and setMovable() on the tool bar containing the menu. The QMenuBar is naturally as wide as it needs to be to hold the menu titles. The other tool bar will also take as much space as it needs to display its tools, and will get an extension menu when there is insufficient space.

  6. The following user says thank you to ChrisW67 for this useful post:

    sangs_shenoy (21st February 2012)

  7. #5
    Join Date
    Feb 2012
    Posts
    4
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Getting the Menubar and Toolbar on the same row in QT

    Thanks ChrisW67, that worked for me!

    Sangeeta.

Similar Threads

  1. Replies: 5
    Last Post: 11th September 2010, 14:29
  2. [QT] MenuBar
    By iVo1d in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2010, 13:14
  3. How to set a Menubar transparent?
    By augusbas in forum Qt Programming
    Replies: 2
    Last Post: 3rd July 2009, 15:55
  4. Bar on menubar?
    By zgulser in forum Qt Tools
    Replies: 6
    Last Post: 14th January 2009, 08:07
  5. Using the menubar
    By Steve in forum Newbie
    Replies: 10
    Last Post: 27th February 2006, 15:59

Tags for this Thread

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.