Results 1 to 2 of 2

Thread: Cannot find id

  1. #1
    Join Date
    Oct 2012
    Posts
    9
    Thanks
    2
    Platforms
    Unix/X11 Windows

    Default Cannot find id

    Hi all,

    I have what I think is a very simple problem.. I want to find out an object's 'id' from javascript. Take the following example:

    Qt Code:
    1. import QtQuick 2.0
    2. Rectangle {
    3. id: test
    4. x: 10; y: 10
    5. width: 122; height: 117
    6. color: "red"
    7. objectName: "testing"
    8.  
    9. MouseArea {
    10. anchors.fill: parent
    11. onClicked:
    12. {
    13. console.log("parent id: " + parent.id);
    14. console.log("parent objectName: " + parent.objectName);
    15. }
    16. }
    17. }
    To copy to clipboard, switch view to plain text mode 

    The output from above is
    Qt Code:
    1. parent id: undefined
    2. parent objectName: testing
    To copy to clipboard, switch view to plain text mode 

    As a solution to my problem I can use objectName and this will work fine. The question is why can't I use id? I can not see any reason you shouldnt be able to do this, it seems perfectly valid to me.

    Kind regards

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Cannot find id

    The id is not a property of the object. it's a reference to the object itself.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. cannot find -lqt-mt
    By mahe2310 in forum Newbie
    Replies: 5
    Last Post: 4th January 2018, 22:43
  2. /usr/bin/ld cannot find -lGL
    By narlapavan in forum Qt Programming
    Replies: 1
    Last Post: 12th July 2013, 12:49
  3. Qt5 cannot find -lGL
    By Viper666 in forum Newbie
    Replies: 1
    Last Post: 20th February 2013, 22:46
  4. Replies: 1
    Last Post: 28th May 2012, 15:06
  5. Qt 4.6.3 where can i find
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 1
    Last Post: 23rd November 2010, 11:28

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.