[Development] Maintaining attributes when creatinng an C++ object to be used in QML

antonio.cano.gomez at ovi.com antonio.cano.gomez at ovi.com
Tue Feb 18 10:59:07 CET 2014


Hi,

I have created the QObject class:

#ifndef BLOOMFILTERS_H
#define BLOOMFILTERS_H


#include <QObject>
#include "svn/bloom-read-only/bloom_filter.hpp"

class Bloomfilters : public QObject
{
    Q_OBJECT
    Q_PROPERTY(bloom_parameters parameters READ parameters WRITE setParameters NOTIFY parametersChanged)
    Q_PROPERTY(bloom_filter filter READ filter WRITE setFilter NOTIFY filterChanged)
    Q_PROPERTY(bool filterCharged READ filterCharged WRITE setFilterCharged NOTIFY filterChargedChanged)
    Q_PROPERTY(QString k READ k WRITE setk NOTIFY kChanged)

public:

    Q_INVOKABLE  void generateFilterInvokable(const QString &cadenaK, const QString &cadenaM) ;

    explicit Bloomfilters(QObject *parent = 0);

    void generateFilter() ;

    Q_INVOKABLE void insertElement(const QString &cadena) ;

    Q_INVOKABLE bool checkElement(const QString &cadena) ;

    bloom_parameters parameters();
    void setParameters(const bloom_parameters &p);

    bloom_filter filter();
    void setFilter(const bloom_filter &f);

    bool filterCharged();
    void setFilterCharged(const bool &f);


    QString  k();
    void setk(const QString &f);


signals:
    void parametersChanged() ;
    void filterChanged() ;
    void filterChargedChanged() ;
    void kChanged() ;

public slots:

private:
    bloom_parameters _parameters ;
    bloom_filter _filter;
    bool _filter_charged;
    QString _k;
};

#endif // BLOOMFILTERS_H


My problem is that values     bloom_parameters _parameters ;   bloom_filter _filter; lost their value when I call to the method     Q_INVOKABLE bool checkElement(const QString &cadena) ;


Can someone help?

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140218/eed8dbba/attachment.html>


More information about the Development mailing list