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. Problem with a scope
Qt 6.11 is out! See what's new in the release blog

Problem with a scope

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 320 Views
  • 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.
  • T Offline
    T Offline
    Traust
    wrote on last edited by Traust
    #1

    I'm having 2 files and FuelGauge.qml and Speedometer.qml, I'm tyring to access some data from FuelGauge.qml, but for some reason I can't access it at all. I want to assing to property fuel value of fuelId.value, but it is out of a scope, so I tried other way, that is commented and it showed error:

    6bf18c77-1b22-4a80-91a3-4eeab2e87257-image.png

    And for use in other files I need to have it in place of first commented property

    import QtQuick 2.14
    import QtQuick.Extras 1.4
    import QtQuick.Controls.Styles 1.4
    import QtQuick.Window 2.14
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
       
        CircularGauge{
            id: gauge
            height: 480
            width: 640
            maximumValue: 100
            
            //property int fuel: mystyle.fuel
    
            style: CircularGaugeStyle{
                id: myStyle
                minimumValueAngle: -150
                maximumValueAngle: 150
                //property int fuel: backgroundRect.value
                background: Rectangle{
                    id: backgroundRect
                    radius: 360
                    color: "black"
                    //property int fuel: fuelId.value
                    FuelGauge{
                        id: fuelId
                        consumption: gauge.value
    
                    }
                }
            }
        }
    }
    
    
    1 Reply Last reply
    0
    • T Offline
      T Offline
      Traust
      wrote on last edited by
      #2

      Generally when I try to access something from inside background: Rectangle{}, I can't do it and I have no idea why.

      MarkkyboyM 1 Reply Last reply
      0
      • T Traust

        Generally when I try to access something from inside background: Rectangle{}, I can't do it and I have no idea why.

        MarkkyboyM Offline
        MarkkyboyM Offline
        Markkyboy
        wrote on last edited by Markkyboy
        #3

        @Traust said in Problem with a scope:

        Generally when I try to access something from inside background: Rectangle{}, I can't do it and I have no idea why.

        Please paste your other qml files for comparison/testing.

        Don't just sit there standing around, pick up a shovel and sweep up!

        I live by the sea, not in it.

        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