<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Custom Component]]></title><description><![CDATA[[[topic:post-is-deleted]]]]></description><link>https://forum.qt.io/topic/116732/custom-component</link><generator>RSS for Node</generator><lastBuildDate>Wed, 04 Nov 2026 19:49:40 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/116732.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 07 Jul 2020 04:56:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Custom Component on Wed, 08 Jul 2020 18:29:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sush123">@<bdi>sush123</bdi></a><br />
i managed to reproduce the error by defining  <strong>InputRow</strong>  like this :<br />
<a href="//InputRow.qml" target="_blank" rel="noopener noreferrer nofollow ugc">//InputRow.qml</a></p>
<pre><code>import QtQuick 2.0
import QtQuick.Layouts 1.12

RowLayout{
    property alias inputContent : content // i use this to access the loader.item
    
    property var component
    Loader{
        id:content
        Layout.fillHeight: true
        Layout.fillWidth: true
        sourceComponent:component
    }
}
</code></pre>
<p dir="auto">and use it</p>
<pre><code>component : Component{
            id: userInput
            Column{...}
}
</code></pre>
<p dir="auto">then the only way i found to access <strong>val1</strong> is this<br />
<strong>userInput.inputContent.item.children[0].children[1].text</strong><br />
but this is too ugly ^^</p>
<p dir="auto">But i have another idea, one solution that will work in any case for sure, no matter how your InputRow is defined<br />
simply create 2 properties,  and assign them when the TextInput text changes</p>
<pre><code>InputRow{
       id: userForm
       property var userInput1
       property var userInput2

       component : 
           Column{
...
          TextInput {
                   id:val1
                   text: "777"
                   onTextChanged: userForm.userInput1 = text
                   Component.onCompleted : userForm.userInput1 = text 
               }
           }
Button{
   onClicked : console.log(userForm.userInput1)
}
</code></pre>
<p dir="auto">only drawback is that you create 2 additional variables</p>
]]></description><link>https://forum.qt.io/post/605625</link><guid isPermaLink="true">https://forum.qt.io/post/605625</guid><dc:creator><![CDATA[ODБOï]]></dc:creator><pubDate>Wed, 08 Jul 2020 18:29:45 GMT</pubDate></item><item><title><![CDATA[Reply to Custom Component on Wed, 08 Jul 2020 17:35:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sush123">@<bdi>sush123</bdi></a> hi</p>
<p dir="auto">I did a quick test, and i don't have <strong>val1 is not defined</strong> error.<br />
Its hard give you an answer because we don't know how <strong>InputRow</strong> is defined.<br />
I did a very simple InputRow Component to test your code</p>
<p dir="auto"><a href="//InputRow.qml" target="_blank" rel="noopener noreferrer nofollow ugc">//InputRow.qml</a></p>
<pre><code>import QtQuick 2.12
import QtQuick.Layouts 1.12
RowLayout{
    property var component
}

</code></pre>
<p dir="auto">//your code</p>
<pre><code>

Window {
    visible: true
    width: 300
    height: 300

    InputRow{

        component:  Column{
            spacing: 10
            Row{

                spacing: 50

                Text{
                    text: "Val1"
                    font.pointSize: 10
                }
                TextInput {
                    id:val1
                    width: 5
                    text: "777"
                    font.pointSize: 10
                }

                Text{
                    text: "m"
                    font.pointSize: 10
                }
            }
            Row{
                spacing: 50

                Text{
                    text: "Val2"
                    font.pointSize: 10
                }

                TextInput {
                    id:val2
                    width: 5
                    text:"888"
                    font.pointSize: 10

                }

                Text{
                    text: "m"
                    font.pointSize: 10
                }
            }
        }                    //End of Column


    }
    
    
    Button{
        text: "Send"

        onClicked:
        {
            console.log("VAL1",val1.text)   //ReferenceError: val1 is not defined,
            console.log("VAL2",val2.text)
            console.log("SEND")

        }
    }
}










</code></pre>
<p dir="auto">i get this output</p>
<pre><code>qml: VAL1 777
qml: VAL2 888
qml: SEND
</code></pre>
<p dir="auto">and no error</p>
]]></description><link>https://forum.qt.io/post/605607</link><guid isPermaLink="true">https://forum.qt.io/post/605607</guid><dc:creator><![CDATA[ODБOï]]></dc:creator><pubDate>Wed, 08 Jul 2020 17:35:26 GMT</pubDate></item></channel></rss>