Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

qdbusxml2cpp generated properties with NOTIFY signals



  • First, it seems that qdbusxml2cpp does not generate NOTIFY signals. Is there a way to get it to do that? Being able to specify a signal with an annotation of some kind seems reasonable. Is there a technical reason why this is not available? This seems like a fairly large gap in DBus and QML integration. As it is, we will likely have to hand code our QDbusAbstractInterface classes, rather than using those generated by qdbusxml2cpp.



  • @greenroom Here is an example to make my question more clear: given the following DBus interface xml

    <!--
               SpeedRpm
               The current handpiece speed in RPM.
    -->
    <property name="speedRpm" type="q" access="read"/>
    

    the following code is generated

    Q_PROPERTY(ushort speedRpm READ speedRpm)
    inline ushort speedRpm() const
    { return qvariant_cast< ushort >(property("speedRpm")); }
    

    Why can't qdbusxml2cpp generate this code

    Q_PROPERTY(ushort speedRpm READ speedRpm NOTIFY speedRpmChanged)
    inline ushort speedRpm() const
    { return qvariant_cast< ushort >(property("speedRpm")); }
    ...
    signals:
    void speedRpmChanged(ushort speed);
    

  • Lifetime Qt Champion

    Hi,

    Just an educated guess: there's no reason from your description to add a signal. You have a read only property. If you want to have an additional signal then your interface declaration should state that as well.

    Not all Qt properties have notification signal.



  • @SGaist I will add some more context to make the use case more clear. The goal is to use this interface from QML. For example,

    Text {
            id: speedText
            text:  HpA.speedRpm
    ...
    }
    

    So, in this case we need the NOTIFY signal.


  • Lifetime Qt Champion

    I understand you need. What I am saying is that you likely need to make your interface declaration more complete in order for the notify signal to be generated.



  • @SGaist said in qdbusxml2cpp generated properties with NOTIFY signals:

    make your interface declaration more complete

    I am sorry, I don't understand what you mean. What is it missing?


  • Lifetime Qt Champion

    It's missing the signal part.


Log in to reply