Results 1 to 6 of 6

Thread: QMenuBar Updates

  1. #1
    Join Date
    Dec 2009
    Posts
    47
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default QMenuBar Updates

    I am trying to update the menu bar for different mdi windows. To do that, I tried to step down the menu tree, removing old QMenu items by removing the action from the QMenuBar, and replacing them using insertMenu(). However, the inserted menu does not appear in the QMenuBar action list, leading to later failure.

    Starting over, using QMenu::clear() also deletes all the owned actions unless they are used elsewhere. In order to be careful and avoid failure modes at close(), the entire menu bar, toolbar, menus, actions and connections seem to need rebuilding at every new subwindow or every change within a subwindow. Is this as it seems or did I miss something?

  2. #2
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: QMenuBar Updates

    Save pointers to your QActions (menuitems) and update them. Do not remove and action and add another action with a different caption but just call setText to update the text in the menu. (Assumption: Menu-layout is the same for all child-windows).
    It's nice to be important but it's more important to be nice.

  3. #3
    Join Date
    Dec 2009
    Posts
    47
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QMenuBar Updates

    To be more explicit, the menus for each child can be different; the children have a stacked widget and each page of the stacked widget can have a different menu. I have saved pointers to the actions in the children, but I was uncertain if removing the action from the menu bar would delete them. (Do saved pointers keep the instantiation from being destroyed once it is removed from the parent?)

    I have since rebuilt the menu bar at every change of subwindow, or stacked widget index, and that works. While I'm sure a merge should be possible, the code was more traceable that way. Thanks for your help.

  4. #4
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: QMenuBar Updates

    It is safe to remove an action from a menu. The idea behind the action is that the same action can be accessed at multiple positions in the GUI, for example in a menu as well as in a toolbar.

    You are not trying to duplicate the SAP-GUI do you? Changing the menubar during runtime is considered bad usability behaviour.
    It's nice to be important but it's more important to be nice.

  5. #5
    Join Date
    Dec 2009
    Posts
    47
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QMenuBar Updates

    My confusion I guess. I've used another framework (MFC) for awhile. In that framework, child windows can merge menus with the main menu. To give an example, suppose the main menu is [File, Window, Help] and, the child window brings up a plot of data. The child window has its own menu, [Graphics], which is then merged to yield [Main, Graphics, Window, Help]. Then the user switches the child window to a table with its own [Edit] menu. The [Graphics] menu is removed and the main menu is merged with the new child menu to give [Main, Edit, Window, Help]. Is this the menu behavior that is in disfavor?

    Sorry, I don't know the SAP-GUI, having never used it. But I do have an existing application that I am rebuilding in QT. It currently has 16 different children, with 10 different models or proxies, and as many submenus. Further, our users have asked for 4 more functions, and we will implement those in 4 more children with varying submenus. What is the proper way to address that need? I hadn't known of any other menuing design.

    BTW, thanks for you help with the action removal. I wasn't sure how reference counts were being done; the parent might have assumed the reference of the child.

  6. #6
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: QMenuBar Updates

    Unfortunately, you have to reimplement that behaviour in Qt. There is no menubar merging feature available.

    The bad behaviour is that during runtime, the menubar changes. It is ok as long as you preserve File/Edit/Help and so an. Bad would be if you invoke one Dialog, the menubar changes to something completely different and the user sees no way back.
    It's nice to be important but it's more important to be nice.

  7. The following user says thank you to axeljaeger for this useful post:

    johnmauer (20th January 2010)

Similar Threads

  1. Thread updates progress bar
    By GianMarco in forum Qt Programming
    Replies: 7
    Last Post: 12th October 2009, 13:29
  2. Painting updates
    By QbelcorT in forum Qt for Embedded and Mobile
    Replies: 6
    Last Post: 29th September 2008, 00:48
  3. Dynamic updates of a QWidget in a QScrollArea
    By plamkata in forum Qt Programming
    Replies: 2
    Last Post: 20th July 2008, 23:45
  4. QDataTable Inserts and Updates
    By ederbs in forum Qt Programming
    Replies: 2
    Last Post: 26th October 2006, 23:23
  5. Dynamic updates to a table widget
    By guiGuy in forum Qt Programming
    Replies: 6
    Last Post: 1st June 2006, 20:24

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.