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. <SOLVED>Qt Property System
Forum Updated to NodeBB v4.3 + New Features

<SOLVED>Qt Property System

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 1.6k 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.
  • G Offline
    G Offline
    GrahamL
    wrote on last edited by
    #1

    Hi
    I have been reading about Qt's property system, in particular the NOTIFY optional specifier.
    Can NOTIFY be used with non Qml/QtQuick applications?

    Thanks

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dbzhang800
      wrote on last edited by
      #2

      Yes, it can be accessed through qt meta system

      @
      QMetaMethod QMetaProperty::notifySignal() const
      @

      1 Reply Last reply
      0
      • G Offline
        G Offline
        GrahamL
        wrote on last edited by
        #3

        Hi
        Thanks for your reply.
        I am having some issues with getting this to work
        in my class declaration I have
        @
        Q_PROPERTY (bool running READ running WRITE setRunning NOTIFY runningChanged)
        .
        .
        .
        private slots:
        void onRunningChanged();
        signals:
        void runningChanged();

        @

        In another class I have
        @
        connect(m_currentSession,&Session::runningChanged,this,&Manager::onRunningChanged);
        @

        But when the property changes my slot is not called

        Am I misunderstanding how it is supposed to work?

        Thanks

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          You need to emit the signal yourself in your C++ code.

          (Z(:^

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dbzhang800
            wrote on last edited by
            #5

            Hi, these has nothing to do with the macro Q_PROPERTY.

            You should always emit the the signal runningChanged by yourself when the property changed, for exmple, in your setRunning() function.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              To add to my fellows, the standard construct is:

              @
              void setMyProperty(int value) {
              if (_myProperty != value) {
              _myProperty = value;
              // start some really cool stuff
              emit myPropertyChanged(_myProperty)
              }
              }
              @

              But it's not the only one possible

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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