#include <QObject>
#include <QVector>
class Foo: public QObject
{
Q_OBJECT
Q_PROPERTY(QVector<bool> b READ getData WRITE setData)
public:
Foo()
{
m_b.resize(30);
for(auto &b:m_b)
{
b = true;
}
}
QVector<bool> getData()
{
return m_b;
}
void inv()
{
for(auto &b:m_b)
{
b = !b;
}
}
void setData(QVector<bool> b)
{
m_b = b;
}
private:
QVector<bool> m_b;
};
class Bar: public QObject
{
Q_OBJECT
Q_PROPERTY(QVector<bool> b WRITE setData)
public:
Bar(){};
void printData()
{
for(auto &b:m_b)
{
qDebug() << b << ' ';
}
}
void setData(QVector<bool> b)
{
m_b = b;
}
private:
QVector<bool> m_b;
};
int main(int argc, char *argv[])
{
Foo foo;
Bar bar;
bar.setData(foo.getData());
bar.printData();
qDebug() << "modify\n";
foo.inv();
bar.setProperty("b", foo.property("b"));
bar.printData();
}