Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Rules for accessing QML properties?
Qt 6.11 is out! See what's new in the release blog

Rules for accessing QML properties?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 274 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #1

    Are there any special rules that apply for accessing properties in a QML file from another QML file?

    I've been going around in circles for the last two days trying to figure out why one QML file cannot see a property from another.

    For example I have two QML files:

    ModeSelection.qml
    ModePreview.qml
    

    ModeSelection contains a boolean property defined as follows:

    import QtQuick 2.7
    import QtQuick.Controls 2.1
    import QtGraphicalEffects 1.0
    import ModePreviewManager 1.0
    import "../Utils"
    import MerlinStyle 1.0
    
    Rectangle {
        id: root
        property bool forceHightlight: false
    ...
    

    There is quite a lot more to it, then this is referenced by ModeDetals.qml

    import QtQuick 2.7
    import QtQuick.Controls 2.1
    import QtQuick.Controls.Styles 1.4
    import QtQuick.Layouts 1.3
    import QtGraphicalEffects 1.0
    import ModePreviewManager 1.0
    import "../Utils"
    import "../Utils/imagepaths.js" as ImagePaths
    import "../Style" as Merlin
    import MerlinStyle 1.0
    
    Item {
        /* Properties */
        Item {
            id: modeSelectionArea
    
          ModeSelection {
            id: localMode
            ....
          }
         ModeSelection {
            id: machineMode
            ...
        }
       Connections {
           target: modeSelectionArea
           onRefreshHighlight: {
               joiner.visible = (ModeSelection.forceHightlight == true)
           }
      }
    ...
    

    The use of ModeSelection in the QML to define objects if ok, but in script ModeSelection is not defined and I can see that in the debugger, also an error is displayed in the Application Output that ModeSelection is undefined.

    What is going wrong or what needs to be done?

    Kind Regards,
    Sy

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jkimmy
      wrote on last edited by
      #2

      You have to reference it using the instance id and not the component name so it becomeslocalMode.forceHighlight.

      1 Reply Last reply
      2
      • SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #3

        @Jkimmy , thank you, I realised this about an hour after I posted, thanks again.

        Kind Regards,
        Sy

        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