Results 1 to 3 of 3

Thread: Invalid alias reference. Unable to find id

  1. #1
    Join Date
    Oct 2007
    Posts
    13
    Thanks
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Invalid alias reference. Unable to find id

    Hi,

    I always get this error message whenever I run my app:
    Qt Code:
    1. qrc:/Page1.qml:8 Invalid alias reference. Unable to find id "textField1"
    To copy to clipboard, switch view to plain text mode 

    What's wrong with my code?

    NOTE: Please forgive me for silly question because I'm still a newbie in QML

    Page1Form.ui.qml
    Qt Code:
    1. import QtQuick 2.7
    2. import QtQuick.Controls 2.0
    3. import QtQuick.Layouts 1.3
    4.  
    5. Item {
    6. property alias textField1: textField1
    7. property alias button1: button1
    8.  
    9. RowLayout {
    10. anchors.horizontalCenter: parent.horizontalCenter
    11. anchors.topMargin: 20
    12. anchors.top: parent.top
    13.  
    14. TextField {
    15. id: textField1
    16. placeholderText: qsTr("Text Field")
    17. }
    18.  
    19. Button {
    20. id: button1
    21. text: qsTr("Press Me")
    22. }
    23. }
    24. }
    To copy to clipboard, switch view to plain text mode 
    Page1.qml
    Qt Code:
    1. import QtQuick 2.7
    2. import Qt.labs.settings 1.0
    3.  
    4. Page1Form {
    5.  
    6. Settings {
    7. id: settings
    8. property alias settings_host: textField1.text
    9. }
    10.  
    11. button1.onClicked: {
    12. console.log("Button Pressed. Entered text: " + textField1.text);
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 
    main.qml
    Qt Code:
    1. import QtQuick 2.7
    2. import QtQuick.Controls 2.0
    3. import QtQuick.Layouts 1.3
    4.  
    5. ApplicationWindow {
    6. visible: true
    7. width: 640
    8. height: 480
    9. title: qsTr("Hello World")
    10.  
    11. SwipeView {
    12. id: swipeView
    13. anchors.fill: parent
    14. currentIndex: tabBar.currentIndex
    15.  
    16. Page1 {
    17. }
    18.  
    19. Page {
    20. Label {
    21. text: qsTr("Second page")
    22. anchors.centerIn: parent
    23. }
    24. }
    25. }
    26.  
    27. footer: TabBar {
    28. id: tabBar
    29. currentIndex: swipeView.currentIndex
    30. TabButton {
    31. text: qsTr("First")
    32. }
    33. TabButton {
    34. text: qsTr("Second")
    35. }
    36. }
    37. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Invalid alias reference. Unable to find id

    Please try if it works if you specify the attribute like this

    Qt Code:
    1. import QtQuick 2.7
    2. import Qt.labs.settings 1.0
    3.  
    4. Page1Form {
    5. id: myPage1Form
    6. Settings {
    7. id: settings
    8. property alias settings_host: myPage1Form.textField1.text
    9. }
    10.  
    11. button1.onClicked: {
    12. console.log("Button Pressed. Entered text: " + textField1.text);
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Oct 2007
    Posts
    13
    Thanks
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: Invalid alias reference. Unable to find id

    Thanks for delayed reply

    @Eeli-K gave me a pretty solution:
    https://forum.qt.io/post/407571

Similar Threads

  1. Unable to reference external library
    By reezeus in forum Installation and Deployment
    Replies: 1
    Last Post: 24th September 2015, 18:03
  2. QSqlTableModel Unable to find table with SQlite
    By qlands in forum Qt Programming
    Replies: 2
    Last Post: 5th July 2011, 15:33
  3. Circular reference ... Unable to write forwarding
    By tonnot in forum General Programming
    Replies: 6
    Last Post: 27th June 2011, 12:26
  4. QPSQL: Unable to find table set in a QSqlTableModel
    By andreabiscuola in forum Qt Programming
    Replies: 7
    Last Post: 19th January 2011, 00:33
  5. QSqlRelationalTableModel settable unable to find
    By nietzsche in forum Qt Programming
    Replies: 0
    Last Post: 25th May 2009, 23:51

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.