Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
None
Description
Below is valid Qt C++ code. However, trying to expose this to D-Bus using qdbuscpp2xml/qdbusxml2cpp might cause problems (see QTBUG-115629 ): setValue() might be exposed twice: Once as a D-Bus Property setter, and once as a D-Bus Method.
Code
Adapted from the example at https://doc.qt.io/qt-6/signalsandslots.html
// counter.h #ifndef COUNTER_H #define COUNTER_H #include <QObject> class Counter : public QObject { Q_OBJECT Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged); public: Counter(QObject* parent = nullptr) : QObject(parent) {} int value() const { return m_value; } public slots: void setValue(int value); signals: void valueChanged(int newValue); private: int m_value = 0; }; #endif
Suggestion
Document that users should either:
- Avoid marking Q_PROPERTY setters as slots, OR
- Use the `-m` option on qdbuscpp2xml to avoid exposing setValue() as a standalone Method