Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML reference to number in Loader
Forum Updated to NodeBB v4.3 + New Features

QML reference to number in Loader

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 148 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    poucz
    wrote on last edited by
    #1

    Hello,

    How to assign reference - not value to Comoponent?

    I have simple code where Im using Loader..
    I using two components, first is for GPIO variable, and second is for bit's in GPIO variable.
    When I click on bit (button) - I need propagate change to global VarGpioPP_OUT.
    How to put reference to component in cascade??

    Thank you

    import QtQuick 2.0
    
    Page{
        property int varGpioPP_OUT:  4
    
        Column{
            Text{ text:"PP Out:"+varGpioPP_OUT}
            Loader{
                sourceComponent: gpioComponent
                onLoaded: item.gpio = varGpioPP_OUT;
            }
        }
    
        Component{
            id: gpioComponent
            Row{
                id: gpioPPOUT
                property int gpio
                onGpioChanged: {
                    for (var i = 0; i < gpioRepeater.count; i++) {
                        gpioRepeater.itemAt(i).item.gpio =gpioPPOUT.gpio; //Need put reference NOT value!, without this gpioDelegat has no value.
                    }
                }
    
                Repeater{
                    id: gpioRepeater
                    model: 8
                    Loader {
                        sourceComponent: gpioDelegat
                        onLoaded: {
                            item.gpio = gpioPPOUT.gpio;
                            item.index = index;
                        }
                    }
                }
            }
        }
    
        Component{
            id: gpioDelegat
            StandardBTN{
                property int gpio
                property int index
                width: 80
                text: gpio&(0x01<<index) ? 1:0
                onClicked: {
                    gpio ^= (0x01<<index);
                }
            }
        }
    }
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved