Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How return QStringListModel ?

How return QStringListModel ?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • freddy311082F Offline
    freddy311082F Offline
    freddy311082
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    1
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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;
      }
      @

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved