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. [Solved by workaround] QQmlListProperty, Qt5.1, QtQuick2
Forum Updated to NodeBB v4.3 + New Features

[Solved by workaround] QQmlListProperty, Qt5.1, QtQuick2

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.7k 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.
  • H Offline
    H Offline
    Hykkel
    wrote on last edited by
    #1

    Hi.

    I'm trying to implement a class that uses the QQmlListProperty. I do however get the following compiler error:
    error: C2661: 'QQmlListProperty<T>::QQmlListProperty' : no overloaded function takes 3 arguments
    with
    [
    T=ContainerObject
    ]

    The ContainerObject works fine i QML (both using qmlRegisterType and setContextProperty(), so it should not be a QObject problem.

    I am using this link as reference:
    http://qt-project.org/doc/qt-5.1/qtqml/qtqml-cppintegration-exposecppattributes.html

    Container class implementation:
    @#ifndef CONTAINER_H
    #define CONTAINER_H

    #include <QObject>
    #include <QQmlListProperty>
    #include "containerobject.h"

    class Container : public QObject
    {
    private:
    //Qt specifics
    Q_OBJECT
    Q_PROPERTY(QQmlListProperty<ContainerObject> words READ getWords NOTIFY containerChanged)

    //Properties
    QList<ContainerObject *>* m_Words;
    
    //Functions (QQmlListProperty specific)
    static void appendWords(QQmlListProperty<ContainerObject> *list, ContainerObject *word);
    

    public:
    explicit Container(QObject *parent = 0);
    QQmlListProperty<ContainerObject> getWords() const;

    signals:
    void containerChanged();

    public slots:

    };

    #endif // CONTAINER_H@

    @#include "container.h"
    #include <QQmlListProperty>

    Container ::Container(QObject *parent) :
    QObject(parent)
    {
    m_Words = new QList<ContainerObject *>();
    }

    QQmlListProperty<ContainerObject> Container::getWords() const
    {
    return QQmlListProperty<ContainerObject>(this, 0, &Container::appendWords);
    // return QQmlListProperty<ContainerObject>(this, 0, &Container::appendWords, NULL, NULL, NULL);
    }

    void Container::appendWords(QQmlListProperty<ContainerObject> *list, ContainerObject *word)
    {
    Container wordList = qobject_cast<Container>(list->object);
    if(word)
    {
    wordList->m_Words->append(word);
    }
    }
    @

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rooi
      wrote on last edited by
      #2

      Hi,

      I'm not sure if it will work for you, but removing the const for getWord() may solve your problem.

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hykkel
        wrote on last edited by
        #3

        Hi.

        I've done a workaround by making a "at(int index)" function which is fine for my solution.

        Thanks for your reply.

        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