Results 1 to 4 of 4

Thread: ReferenceError when moving from QtQuick 1 to QtQuick 2 in example code

  1. #1
    Join Date
    Aug 2008
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default ReferenceError when moving from QtQuick 1 to QtQuick 2 in example code

    I am looking at the CollapsiblePanel example found here:

    http://developer.nokia.com/community...Panel_with_QML

    It was done with QtQuick 1.0

    With Qt 5.2.1 I created a QtQuick 2.0 project and copied in the main.qml, CollapsiblePanel.qml, and icons. I changed the imports from QtQuick 1.0 to QtQuick 2.0. When clicking on an item in the panel, the Application Output window displays

    file:///Projects/buildCollapsiblePanel/qml/CollapsiblePanel/main.qml:98: ReferenceError: myRect is not defined

    For some reason it is unable to access the CollapsiblePanel ID from the ListView delegate.

    Why is this broken? Is there a new and better way to do this?

    Thanks ......
    Last edited by gmat4321; 5th March 2014 at 18:25.

  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: ReferenceError when moving from QtQuick 1 to QtQuick 2 in example code

    There is no element in main.qml with id "myRect"

    There is also no context property with that name.

    Which element is this supposed to refer to?

    Cheers,
    _

  3. #3
    Join Date
    Aug 2008
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: ReferenceError when moving from QtQuick 1 to QtQuick 2 in example code

    "myRect" is the id of the CollapsiblePanel Component from which the panel objects (panel1, panel2, panel3) come from. The CollapsiblePanel contains the ListView, and the ListView's delegate is found back in the main.qml code.

    As noted with Qt 5.2.1 and QtQuick 1 this works, but with Qt 5.2.1 and QtQuick 2 it does not.

    -


    Added after 35 minutes:


    A solution to the problem is to move Component (ie: myDelegate) from main.qml to CollapsiblePanel.qml. Fix up the LIstView delegate assignment and remove the customDelegate alias.

    Apparently you can call from the CollapsiblePanel Component into main.qml but not the other way around.

    I would really like to know if this is as intended (ie: there was a bug in QtQuick 1 that is now fixed) or is there now a bug (ie: QtQuick 1 was correct).

    (sigh)

    -
    Last edited by gmat4321; 5th March 2014 at 19:35.

  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: ReferenceError when moving from QtQuick 1 to QtQuick 2 in example code

    I am pretty sure the QtQuick2 behavior is correct. Which of the three instances of CollapsiblePanel would myRect refer to?

    Cheers,
    _

Similar Threads

  1. Import QtQuick 2.0 or 2.1 or 2.2?
    By pherthyl in forum Qt Quick
    Replies: 2
    Last Post: 9th January 2014, 21:13
  2. QtQuick structure
    By codeman in forum Qt Quick
    Replies: 4
    Last Post: 21st May 2013, 11:35
  3. QtQuick 2.1
    By shadowroot in forum Qt Quick
    Replies: 1
    Last Post: 6th April 2013, 09:44
  4. What is QtQuick/QML really for?
    By Huk in forum Qt Quick
    Replies: 7
    Last Post: 21st June 2012, 21:33
  5. Designer or QtQuick?
    By Jeffb in forum Qt Quick
    Replies: 5
    Last Post: 9th August 2011, 07:38

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.