How return QStringListModel ?
-
Hi guys !!!
I have the following code:
@
QStringListModel System::users()
{
QStringListModel users;
QStringList lUsers;
lUsers.append("testing");
users.setStringList(lUsers);
return users;
}@This method give me the following error:
@
/home/freddy/Trabajo/bpg/project-qtcreator/adviser/system/System.cpp:145: error: call to deleted constructor of 'QStringListModel'
return users;
^~~~~
/usr/include/qt/QtCore/qstringlistmodel.h:79: function has been explicitly marked deleted here
Q_DISABLE_COPY(QStringListModel)
^
/usr/include/qt/QtCore/qglobal.h:978: expanded from macro 'Q_DISABLE_COPY'
Class(const Class &) Q_DECL_EQ_DELETE;
^
@does any one know about it ??? because I need to return a QStringListModel object
thanks
-
Hi,
You can't copy QObject derived class, you need to allocated an new QStringListModel and return the pointer to it
@
QStringListModel *System::users()
{
QStringListModel *users = new QStringListModel;
QStringList lUsers;
lUsers.append("testing");
users->setStringList(lUsers);
return users;
}
@