aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/qml')
-rw-r--r--examples/qml/referenceexamples/attached/birthdayparty.cpp2
-rw-r--r--examples/qml/referenceexamples/binding/birthdayparty.cpp2
-rw-r--r--examples/qml/referenceexamples/coercion/birthdayparty.cpp2
-rw-r--r--examples/qml/referenceexamples/default/birthdayparty.cpp2
-rw-r--r--examples/qml/referenceexamples/grouped/birthdayparty.cpp2
-rw-r--r--examples/qml/referenceexamples/methods/birthdayparty.cpp2
-rw-r--r--examples/qml/referenceexamples/properties/birthdayparty.cpp24
-rw-r--r--examples/qml/referenceexamples/properties/birthdayparty.h4
-rw-r--r--examples/qml/referenceexamples/signal/birthdayparty.cpp2
-rw-r--r--examples/qml/referenceexamples/valuesource/birthdayparty.cpp2
-rw-r--r--examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.cpp3
-rw-r--r--examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.cpp3
12 files changed, 39 insertions, 11 deletions
diff --git a/examples/qml/referenceexamples/attached/birthdayparty.cpp b/examples/qml/referenceexamples/attached/birthdayparty.cpp
index da0cb800fc..888aafbc18 100644
--- a/examples/qml/referenceexamples/attached/birthdayparty.cpp
+++ b/examples/qml/referenceexamples/attached/birthdayparty.cpp
@@ -81,7 +81,7 @@ void BirthdayParty::setHost(Person *c)
QQmlListProperty<Person> BirthdayParty::guests()
{
- return {this, m_guests};
+ return {this, &m_guests};
}
int BirthdayParty::guestCount() const
diff --git a/examples/qml/referenceexamples/binding/birthdayparty.cpp b/examples/qml/referenceexamples/binding/birthdayparty.cpp
index 866c1f6968..cfedf84be0 100644
--- a/examples/qml/referenceexamples/binding/birthdayparty.cpp
+++ b/examples/qml/referenceexamples/binding/birthdayparty.cpp
@@ -87,7 +87,7 @@ void BirthdayParty::setHost(Person *c)
QQmlListProperty<Person> BirthdayParty::guests()
{
- return QQmlListProperty<Person>(this, m_guests);
+ return QQmlListProperty<Person>(this, &m_guests);
}
int BirthdayParty::guestCount() const
diff --git a/examples/qml/referenceexamples/coercion/birthdayparty.cpp b/examples/qml/referenceexamples/coercion/birthdayparty.cpp
index 1bae55076c..81db8ab1b8 100644
--- a/examples/qml/referenceexamples/coercion/birthdayparty.cpp
+++ b/examples/qml/referenceexamples/coercion/birthdayparty.cpp
@@ -66,7 +66,7 @@ void BirthdayParty::setHost(Person *c)
QQmlListProperty<Person> BirthdayParty::guests()
{
- return {this, m_guests};
+ return {this, &m_guests};
}
int BirthdayParty::guestCount() const
diff --git a/examples/qml/referenceexamples/default/birthdayparty.cpp b/examples/qml/referenceexamples/default/birthdayparty.cpp
index 1bae55076c..81db8ab1b8 100644
--- a/examples/qml/referenceexamples/default/birthdayparty.cpp
+++ b/examples/qml/referenceexamples/default/birthdayparty.cpp
@@ -66,7 +66,7 @@ void BirthdayParty::setHost(Person *c)
QQmlListProperty<Person> BirthdayParty::guests()
{
- return {this, m_guests};
+ return {this, &m_guests};
}
int BirthdayParty::guestCount() const
diff --git a/examples/qml/referenceexamples/grouped/birthdayparty.cpp b/examples/qml/referenceexamples/grouped/birthdayparty.cpp
index 1bae55076c..81db8ab1b8 100644
--- a/examples/qml/referenceexamples/grouped/birthdayparty.cpp
+++ b/examples/qml/referenceexamples/grouped/birthdayparty.cpp
@@ -66,7 +66,7 @@ void BirthdayParty::setHost(Person *c)
QQmlListProperty<Person> BirthdayParty::guests()
{
- return {this, m_guests};
+ return {this, &m_guests};
}
int BirthdayParty::guestCount() const
diff --git a/examples/qml/referenceexamples/methods/birthdayparty.cpp b/examples/qml/referenceexamples/methods/birthdayparty.cpp
index 7e750e4f4b..4b30d31aeb 100644
--- a/examples/qml/referenceexamples/methods/birthdayparty.cpp
+++ b/examples/qml/referenceexamples/methods/birthdayparty.cpp
@@ -67,7 +67,7 @@ void BirthdayParty::setHost(Person *c)
QQmlListProperty<Person> BirthdayParty::guests()
{
- return {this, m_guests};
+ return {this, &m_guests};
}
int BirthdayParty::guestCount() const
diff --git a/examples/qml/referenceexamples/properties/birthdayparty.cpp b/examples/qml/referenceexamples/properties/birthdayparty.cpp
index 9abb08dbd9..fe6abab3f5 100644
--- a/examples/qml/referenceexamples/properties/birthdayparty.cpp
+++ b/examples/qml/referenceexamples/properties/birthdayparty.cpp
@@ -71,7 +71,9 @@ QQmlListProperty<Person> BirthdayParty::guests()
&BirthdayParty::appendGuest,
&BirthdayParty::guestCount,
&BirthdayParty::guest,
- &BirthdayParty::clearGuests};
+ &BirthdayParty::clearGuests,
+ &BirthdayParty::replaceGuest,
+ &BirthdayParty::removeLastGuest};
}
void BirthdayParty::appendGuest(Person* p) {
@@ -93,6 +95,16 @@ void BirthdayParty::clearGuests() {
m_guests.clear();
}
+void BirthdayParty::replaceGuest(int index, Person *p)
+{
+ m_guests[index] = p;
+}
+
+void BirthdayParty::removeLastGuest()
+{
+ m_guests.removeLast();
+}
+
// ![0]
void BirthdayParty::appendGuest(QQmlListProperty<Person>* list, Person* p) {
@@ -103,6 +115,16 @@ void BirthdayParty::clearGuests(QQmlListProperty<Person>* list) {
reinterpret_cast< BirthdayParty* >(list->data)->clearGuests();
}
+void BirthdayParty::replaceGuest(QQmlListProperty<Person> *list, int i, Person *p)
+{
+ reinterpret_cast< BirthdayParty* >(list->data)->replaceGuest(i, p);
+}
+
+void BirthdayParty::removeLastGuest(QQmlListProperty<Person> *list)
+{
+ reinterpret_cast< BirthdayParty* >(list->data)->removeLastGuest();
+}
+
Person* BirthdayParty::guest(QQmlListProperty<Person>* list, int i) {
return reinterpret_cast< BirthdayParty* >(list->data)->guest(i);
}
diff --git a/examples/qml/referenceexamples/properties/birthdayparty.h b/examples/qml/referenceexamples/properties/birthdayparty.h
index fb8b63a79d..a5704972cc 100644
--- a/examples/qml/referenceexamples/properties/birthdayparty.h
+++ b/examples/qml/referenceexamples/properties/birthdayparty.h
@@ -79,12 +79,16 @@ public:
int guestCount() const;
Person *guest(int) const;
void clearGuests();
+ void replaceGuest(int, Person*);
+ void removeLastGuest();
private:
static void appendGuest(QQmlListProperty<Person>*, Person*);
static int guestCount(QQmlListProperty<Person>*);
static Person* guest(QQmlListProperty<Person>*, int);
static void clearGuests(QQmlListProperty<Person>*);
+ static void replaceGuest(QQmlListProperty<Person>*, int, Person*);
+ static void removeLastGuest(QQmlListProperty<Person>*);
Person *m_host;
QVector<Person *> m_guests;
diff --git a/examples/qml/referenceexamples/signal/birthdayparty.cpp b/examples/qml/referenceexamples/signal/birthdayparty.cpp
index 9d34cdf146..405c8af940 100644
--- a/examples/qml/referenceexamples/signal/birthdayparty.cpp
+++ b/examples/qml/referenceexamples/signal/birthdayparty.cpp
@@ -82,7 +82,7 @@ void BirthdayParty::setHost(Person *c)
QQmlListProperty<Person> BirthdayParty::guests()
{
- return {this, m_guests};
+ return {this, &m_guests};
}
int BirthdayParty::guestCount() const
diff --git a/examples/qml/referenceexamples/valuesource/birthdayparty.cpp b/examples/qml/referenceexamples/valuesource/birthdayparty.cpp
index 68d5767e8d..6a5e67aa0d 100644
--- a/examples/qml/referenceexamples/valuesource/birthdayparty.cpp
+++ b/examples/qml/referenceexamples/valuesource/birthdayparty.cpp
@@ -82,7 +82,7 @@ void BirthdayParty::setHost(Person *c)
QQmlListProperty<Person> BirthdayParty::guests()
{
- return {this, m_guests};
+ return {this, &m_guests};
}
int BirthdayParty::guestCount() const
diff --git a/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.cpp b/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.cpp
index ac680bb9c9..a8e14db542 100644
--- a/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.cpp
+++ b/examples/qml/tutorials/extending-qml/chapter5-listproperties/piechart.cpp
@@ -68,7 +68,8 @@ void PieChart::setName(const QString &name)
//![0]
QQmlListProperty<PieSlice> PieChart::slices()
{
- return QQmlListProperty<PieSlice>(this, nullptr, &PieChart::append_slice, nullptr, nullptr, nullptr);
+ return QQmlListProperty<PieSlice>(this, nullptr, &PieChart::append_slice, nullptr,
+ nullptr, nullptr, nullptr, nullptr);
}
void PieChart::append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice)
diff --git a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.cpp b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.cpp
index 1c712c887a..536c0e16ae 100644
--- a/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.cpp
+++ b/examples/qml/tutorials/extending-qml/chapter6-plugins/import/piechart.cpp
@@ -67,7 +67,8 @@ void PieChart::setName(const QString &name)
QQmlListProperty<PieSlice> PieChart::slices()
{
- return QQmlListProperty<PieSlice>(this, nullptr, &PieChart::append_slice, nullptr, nullptr, nullptr);
+ return QQmlListProperty<PieSlice>(this, nullptr, &PieChart::append_slice, nullptr,
+ nullptr, nullptr, nullptr, nullptr);
}
void PieChart::append_slice(QQmlListProperty<PieSlice> *list, PieSlice *slice)