Results 1 to 5 of 5

Thread: Menubar implementation

  1. #1
    Join Date
    Jan 2008
    Posts
    20
    Thanks
    1

    Default Menubar implementation

    Hi,

    I'm trying to understand the inner working of the menubar control (not how to use it, but how it is implemented). I already figured out that MenuBar.qml uses MenuBarPrivate, which is actually a QQuickMenuBar object (same for the Menu - QQuickMenu). What I'm failing to understand is how the MenuBar uses the Menu components which are defined inside. I can see that the MenuBar uses a Repeater (model is the QQuickMenuBar menus property), but I can't figure out how that list is populated with the menus that are defined in the MenuBar component.
    Anybody an idea how that is done, I'm sure i'm overlooking something stupid...
    Thanks,

    Jan

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Menubar implementation

    I haven't looked at the menu bar implementation,. but usually the type that handles "children" is QQmlListProperty.

    Cheers,
    _

  3. #3
    Join Date
    Jan 2008
    Posts
    20
    Thanks
    1

    Default Re: Menubar implementation

    Yes, that i figured out. There is a QProperty in the QQuickMenuBar "menus" which is indeed a QQmlListProperty. The MenuBar control uses this in a repeater to visualize the menu. That I already understood, but what I don't understand is how that QQmlListProperty is populated with the childcomponents that you define in your MenuBar...

    Jan

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Menubar implementation

    That "menus" property is likely marked as the "default" property, so writing this
    Qt Code:
    1. MenuBar {
    2. Menu {}
    3. Menu {}
    4. }
    To copy to clipboard, switch view to plain text mode 
    is equivalent to
    Qt Code:
    1. MenuBar {
    2. menus: [ Menu {}, Menu {} ]
    3. }
    To copy to clipboard, switch view to plain text mode 
    Two instance of Menu get created and appended to the "menus" QQmlListProperty.

    Cheers,
    _

  5. #5
    Join Date
    Jan 2008
    Posts
    20
    Thanks
    1

    Default Re: Menubar implementation

    Yes, that's it probably. In the qquickmenubar I see: Q_CLASSINFO("DefaultProperty", "menus"). I didn't know about the default property.
    Thanks!

    Jan

Similar Threads

  1. [QT] MenuBar
    By iVo1d in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2010, 14:14
  2. How to set a Menubar transparent?
    By augusbas in forum Qt Programming
    Replies: 2
    Last Post: 3rd July 2009, 16:55
  3. Bar on menubar?
    By zgulser in forum Qt Tools
    Replies: 6
    Last Post: 14th January 2009, 09:07
  4. menuBar() Problem
    By Cutey in forum Qt Programming
    Replies: 9
    Last Post: 25th January 2007, 12:50
  5. Using the menubar
    By Steve in forum Newbie
    Replies: 10
    Last Post: 27th February 2006, 16:59

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.