Hello,
A fairly common format for a Qt class, which I make use of often, is:
{
Q_OBJECT
Q_PROPERTY(double wheelBarrow READ wheelBarrow WRITE setWheelBarrow);
.
.
public:
// Constructor:
.
.
void setWheelBarrow(const double &newWheelBarrow);
etc.
public slots:
void updateWheelBarrow(const double &newWheelBarrow);
.
.
.
};
class Garden : public QWidget
{
Q_OBJECT
Q_PROPERTY(double wheelBarrow READ wheelBarrow WRITE setWheelBarrow);
.
.
public:
// Constructor:
.
.
void setWheelBarrow(const double &newWheelBarrow);
etc.
public slots:
void updateWheelBarrow(const double &newWheelBarrow);
.
.
.
};
To copy to clipboard, switch view to plain text mode
Quite often, setWheelBarrow and updateWheelBarrow do different things (for example, updateWheelBarrow may need to update some other parameters which depend on wheelBarrow, which setWheelBarrow assumes will be set directly by the parent) , but sometimes they do exactly the same thing. In the cases where they are exactly the same, can the same function be used? Or is it always necessary for Q_PROPERTY functions and slots to be separate entities?
Thanks,
Stephen.
Bookmarks