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. error: use of deleted function 'QStringListModel& QStringListModel::operator=(const QStringListModel&)'
Forum Updated to NodeBB v4.3 + New Features

error: use of deleted function 'QStringListModel& QStringListModel::operator=(const QStringListModel&)'

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 223 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.
  • C Offline
    C Offline
    c0ntrarian
    wrote on 5 Oct 2021, 21:08 last edited by
    #1

    Hi all, I have been spending 3 weeks trying to get a basic app off the ground learning QT and have been pulling my hair out over this. I am trying to understand why I cannot set a Q_PROPERTY to a QStringListModel. Every time I setup the methods for this property I always receive this error from the compiler:

    /home/drew/build-GEO-Desktop_Qt_6_2_0_GCC_64bit-Debug/GEO_autogen/EWIEGA46WW/moc_serial.cpp:120: error: use of deleted function 'QStringListModel& QStringListModel::operator=(const QStringListModel&)'
    error: use of deleted function 'QStringListModel& QStringListModel::operator=(const QStringListModel&)'
    120 | case 1: reinterpret_cast< QStringListModel>(_v) = _t->comModel(); break;
    | ^

    public:    
        explicit Serial(QObject *parent = nullptr);
        Q_PROPERTY(QStringListModel comModel READ comModel NOTIFY n_comModel)
        QStringListModel comModel();
    signals:
        void comboBoxSerialPortsChanged();
        void n_comModel();
    
    
    #ifndef QT_NO_PROPERTIES
        else if (_c == QMetaObject::ReadProperty) {
            auto *_t = static_cast<Serial *>(_o);
            (void)_t;
            void *_v = _a[0];
            switch (_id) {
            case 0: *reinterpret_cast< QList<QSerialPortInfo>*>(_v) = _t->comboBoxSerialPorts(); break;
            case 1: *reinterpret_cast< QStringListModel*>(_v) = _t->comModel(); break;
            default: break;
            }
        } else if (_c == QMetaObject::WriteProperty) {
        } else if (_c == QMetaObject::ResetProperty) {
        } else if (_c == QMetaObject::BindableProperty) {
        }
    

    What exactly does this mean? How can I go about resolving this? Is this the best way to provide QML variables to use?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 5 Oct 2021, 21:33 last edited by
      #2

      Hi,

      Because you can't copy QObject based classes. You should allocate your model on the heap and your property should return a pointer to a QStringListModel.

      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
      3

      1/2

      5 Oct 2021, 21:08

      • Login

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