In header file, I have this:
private:
Q_PROPERTY(QList <QList <QString> > dummy READ dummy WRITE setDummy NOTIFY dummyChanged)
QList <QList <QString> > m_dummy;
public:
QList <QList <QString> > dummy() const
{
return m_dummy;
}
public slots:
void setDummy(QList <QList <QString> > arg)
{
if (m_dummy == arg)
return;
m_dummy = arg;
emit dummyChanged(arg);
}
signals:
void dummyChanged(QList <QList <QString> > arg);
In CPP file, in a function I have written:
QList <QString> p;
p.push_back("abc");
p.push_back("def");
QList <QString> q;
q.push_back("ghi");
q.push_back("jkl");
dummy.push_back (p);
dummy.push_back (q);
Compilation error I get is:
error: '((TablesAndChartsDatabaseQueries*)this)->TablesAndChartsDatabaseQueries::dummy' does not have class type dummy.push_back (p);
What point am I missing?
thomas_b pointed out the error correctly as follows:
I guess you should call m_dummy.push_back(p) and not dummy.push_back(p) because dummy is the method to get the "dummy".
I think, a better way to set the desired value would have been to call the setDummy
function and let it do the job it is created for.
QList <QList <QString> > localDummy;
QList <QString> p;
p.push_back("abc");
p.push_back("def");
QList <QString> q;
q.push_back("ghi");
q.push_back("jkl");
localDummy.push_back (p);
localDummy.push_back (q);
setDummy (localDummy);