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. NOTIFY on grouped properties
Forum Updated to NodeBB v4.3 + New Features

NOTIFY on grouped properties

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 488 Views 2 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.
  • ocgltdO Offline
    ocgltdO Offline
    ocgltd
    wrote on last edited by ocgltd
    #1

    I am trying to use 'grouped properties' and want to be able to use onXChanged for my grouped properties. But I get this error

    QQmlExpression: Expression qrc:/main.qml:13:5 depends on non-NOTIFYable properties:
        Appearance::colors
    

    referring to

    color: { return Appearance.colors.backgroundColor }
    

    And main.qml is

    Window {
        width: 640
        height: 480
        visible: true
        title: qsTr("Test for Appearance")
    
        color: { return Appearance.colors.backgroundColor; }
    }
    ...
    
    My Appearance class (which is a singleton):
    
    class Appearance : public QObject, public Singleton<Appearance>
    {
        friend class TeliumLib::TL_Singleton<Appearance>;
        Q_OBJECT
        Q_PROPERTY(Colors* colors READ colorsGroup NOTIFY sig_colorsChange)
        Q_PROPERTY(Fonts* fonts READ fontsGroup)
        Q_PROPERTY(Icons* icons READ iconsGroup)
    public:
        TLQ_A_Colors* colorsGroup();
        TLQ_A_Fonts* fontsGroup();
        TLQ_A_Icons* iconsGroup();
    private:
        Colors* m_colorsPtr;
        Fonts* m_fontsPtr;
        Icons* m_iconsPtr;
    }; 
    

    My Colors class is:

    class Colors : public QObject
    {
        Q_OBJECT
    
        Q_PROPERTY(QString background READ background NOTIFY sig_backgroundChanged)
    
    raven-worxR 1 Reply Last reply
    0
    • ocgltdO ocgltd

      @raven-worx My intention was to allow this property to change. But I found the issue...if I add notify to either APpearance or Color QML files, then it complains. But if I add NOTIFY to BOTH Appearance and COlors then it no longer complains. I'm not sure what signal it will receive...but I can figure that out.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #4

      @ocgltd
      EVERY property you use in a statement must either be CONSTANT or have a NOTIFY signal.
      depending on which property gets changed, this notifier signal causes a reevaluation of the property binding.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • ocgltdO ocgltd

        I am trying to use 'grouped properties' and want to be able to use onXChanged for my grouped properties. But I get this error

        QQmlExpression: Expression qrc:/main.qml:13:5 depends on non-NOTIFYable properties:
            Appearance::colors
        

        referring to

        color: { return Appearance.colors.backgroundColor }
        

        And main.qml is

        Window {
            width: 640
            height: 480
            visible: true
            title: qsTr("Test for Appearance")
        
            color: { return Appearance.colors.backgroundColor; }
        }
        ...
        
        My Appearance class (which is a singleton):
        
        class Appearance : public QObject, public Singleton<Appearance>
        {
            friend class TeliumLib::TL_Singleton<Appearance>;
            Q_OBJECT
            Q_PROPERTY(Colors* colors READ colorsGroup NOTIFY sig_colorsChange)
            Q_PROPERTY(Fonts* fonts READ fontsGroup)
            Q_PROPERTY(Icons* icons READ iconsGroup)
        public:
            TLQ_A_Colors* colorsGroup();
            TLQ_A_Fonts* fontsGroup();
            TLQ_A_Icons* iconsGroup();
        private:
            Colors* m_colorsPtr;
            Fonts* m_fontsPtr;
            Icons* m_iconsPtr;
        }; 
        

        My Colors class is:

        class Colors : public QObject
        {
            Q_OBJECT
        
            Q_PROPERTY(QString background READ background NOTIFY sig_backgroundChanged)
        
        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by raven-worx
        #2

        @ocgltd
        this

        Q_PROPERTY(Colors* colors READ colorsGroup)

        should be

        Q_PROPERTY(Colors* colors READ colorsGroup CONSTANT)

        and you should also treat it like this. Means the Colors instance must not change for the QObjects lifetime.
        if thats not your intention then this property also needs a NOTIFY signal.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        ocgltdO 1 Reply Last reply
        1
        • raven-worxR raven-worx

          @ocgltd
          this

          Q_PROPERTY(Colors* colors READ colorsGroup)

          should be

          Q_PROPERTY(Colors* colors READ colorsGroup CONSTANT)

          and you should also treat it like this. Means the Colors instance must not change for the QObjects lifetime.
          if thats not your intention then this property also needs a NOTIFY signal.

          ocgltdO Offline
          ocgltdO Offline
          ocgltd
          wrote on last edited by ocgltd
          #3

          @raven-worx My intention was to allow this property to change. But I found the issue...if I add notify to either APpearance or Color QML files, then it complains. But if I add NOTIFY to BOTH Appearance and COlors then it no longer complains. I'm not sure what signal it will receive...but I can figure that out.

          raven-worxR 1 Reply Last reply
          0
          • ocgltdO ocgltd

            @raven-worx My intention was to allow this property to change. But I found the issue...if I add notify to either APpearance or Color QML files, then it complains. But if I add NOTIFY to BOTH Appearance and COlors then it no longer complains. I'm not sure what signal it will receive...but I can figure that out.

            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #4

            @ocgltd
            EVERY property you use in a statement must either be CONSTANT or have a NOTIFY signal.
            depending on which property gets changed, this notifier signal causes a reevaluation of the property binding.

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            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