Cannot assign to non-existent default property error



  • Hi,

    Im struggling with error "Cannot assign to non-existent default property". Please check code below (2 files).
    It's not possible to create an instance of BlinkingTimer inside CowbellTimer. Any ideas will be helpful - i guess that solution is really simply but, hmmm .... i cannot find it.

    BlinkingTimer.qml

    import QtQuick 2.0
    
    Timer {
    
        interval: 50
        triggeredOnStart: false
        running: false
    
        onTriggered:{
                statusIndicator.active = false
        }
    }
    

    CowbellTimer.qml

    import QtQuick 2.0
    import QtMultimedia 5.8
    
    Timer {
        id: cowbellTimer
        interval: 1000
        triggeredOnStart: true
        running: false
        repeat: true
    
        BlinkingTimer {
            id: cowbellBlinking
        }
    }
    
    

    Cheers and thanks!



  • @torrancee It looks like Timer doesn't have the default property (the property which you can create unnamed, using only the type, as you do now), as the error message indicates. You can try something like this (simplified, doesn't use your component names):

    Timer {
          property Timer t2: Timer {
          }
      }
    


  • @Eeli-K I replaced blinkingTimer.qml with your solution (just to ensure if its compiling) but error its still same



  • @torrancee You should replace the inner timer (BlinkingTimer) with a named property:

    property BlinkingTimer t2: BlinkingTimer {
    

    I don't know if this works, but a simple inner Timer as the attempted but non-existent default property gives the error for me, while the named property doesn't.



  • It's ok ! Thank you. I paste the code for other users:

    CowbellTimer.qml

    Timer {
        id: cowbellTimer
        interval: 1000
        triggeredOnStart: true
        running: false
        repeat: true
    
        property BlinkingTimer t2: BlinkingTimer {
            id: cowbellBlinking
        }
    }
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.