Chapter 2: Connecting to C++ Methods and Signals

时间:2021-03-19 00:13:06

Qt slot  或者 using Q_INVOKABLE 都可以被qml调用

 

 public:
     ...
     Q_INVOKABLE void clearChart();

 signals:
     void chartCleared();

 

qml中对应onChartCleared

 

Chapter 3: Adding Property Bindings

allows values of different elements to be synchronized automatically

让不同元素的值自动同步

The "color: chartA.color" statement binds the color value of chartB to the color of chartA

 class PieChart : public QDeclarativeItem
 {
     ...
     Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
 public:
     ...
 signals:
     void colorChanged();
     ...
 };