Results 1 to 6 of 6

Thread: Warnings when creating embedded Menus with Instantiator

  1. #1
    Join Date
    Nov 2014
    Posts
    20
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11

    Default Warnings when creating embedded Menus with Instantiator

    I'd like to create a Menu in QML application that has other Menus depending on some Model. When I use Instantiator for that, items which are being created are parented to the Instantiator itself and when adding them to top-level Menu, it complains about `__parentMenu` being null

    Qt Code:
    1. Menu {
    2. title: qsTr("Top-Level Menu")
    3. id: topMenu
    4.  
    5. Instantiator {
    6. model: aTopLevelModel
    7. onObjectAdded: topMenu.insertItem( index, object )
    8. onObjectRemoved: topMenu.removeItem( object )
    9.  
    10. delegate: Menu {
    11. id: innerMenu
    12. title: qsTr("Inner Menu")
    13.  
    14. Instantiator {
    15. model: aTopLevelModel.getInnerModel(index)
    16. onObjectAdded: innerMenu.insertItem( index, object )
    17. onObjectRemoved: innerMenu.removeItem( object )
    18.  
    19. delegate: MenuItem {
    20. text: qsTr("Menu action!")
    21. onTriggered: {
    22. console.log("Action of inner menu")
    23. }
    24. }
    25. }
    26. }
    27. }
    28. }
    To copy to clipboard, switch view to plain text mode 
    The warning I'm observing is:
    Qt Code:
    1. Menu.qml:149: TypeError: Cannot read property '__contentItem' of null
    To copy to clipboard, switch view to plain text mode 
    Where the line 149 is
    Qt Code:
    1. property var __parentContentItem: __parentMenu.__contentItem
    To copy to clipboard, switch view to plain text mode 
    How can I overcome this Warning being produced?

    Qt version is 5.5.1. This behavior is observed undre OS X and Windows versions of Qt.

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

    Default Re: Warnings when creating embedded Menus with Instantiator

    I guess the only way to fix this is in Menu.qml

    That line needs to be something like
    Qt Code:
    1. property var __parentContentItem: __parentMenu ? __parentMenu.__contentItem : null
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  3. #3
    Join Date
    Nov 2014
    Posts
    20
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11

    Default Re: Warnings when creating embedded Menus with Instantiator

    Should I then send my edits to Qt repo? I mean, officially I would patch Qt, so I would need to ship modified Qt and all that stuff with licenses, you know..

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

    Default Re: Warnings when creating embedded Menus with Instantiator

    If you can verify that this fixes the problem, it would be great is this would end up in Qt proper.
    First step for that is to create a ticket at https://bugreports.qt.io/secure/Dashboard.jspa ideally with a test case that shows the problem.

    For you locally it depends on the license you are using Qt with.

    The commerical license doesn't require you to ship any source, the open source license already require you to make the sources of Qt available to whoever you distribute the software to.

    Cheers,
    _

  5. #5
    Join Date
    Nov 2014
    Posts
    20
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11

    Default Re: Warnings when creating embedded Menus with Instantiator

    The OpenSource License doesn't require me to ship Qt if I didn't modify it.
    Yes, I'll create a bug. Thank you.

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Warnings when creating embedded Menus with Instantiator

    Quote Originally Posted by ribtoks View Post
    The OpenSource License doesn't require me to ship Qt if I didn't modify it.
    Right, you can also offer a download of the Qt code.
    In case of a modifcation you would need to offer download of your modifed source instead of just having the official Qt sources mirrored.

    Cheers,
    _

Similar Threads

  1. Deprecated warnings still appear
    By Caius Aérobus in forum Qt Programming
    Replies: 0
    Last Post: 29th March 2010, 08:25
  2. Where are my compiler warnings?
    By drhex in forum General Programming
    Replies: 5
    Last Post: 18th February 2009, 21:28
  3. Crosscompiling warnings
    By SteM in forum Installation and Deployment
    Replies: 1
    Last Post: 2nd August 2007, 20:26
  4. Makefile warnings
    By Doug Broadwell in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2007, 19:42
  5. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 22:14

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.