webengine function does not take 0 arguments



  • hello,
    I have in file .h :

    Q_PROPERTY(QJsonArray answerToLife READ answerToLife NOTIFY answerToLifeChanged)
    . . . . . 
    public:
    	QJsonArray answerToLife(QJsonArray array_parameter);
    

    In file .cpp i have:

    void EngineIndexHtml::changeAnswerToLife()
    {
    	emit answerToLifeChanged(array_parameter);
    }
    

    When i Build the program i have this error:

    answerToLife': function does not take 0 arguments
    Where I wrong? 
    Thanks for your help

  • Moderators

    A read function should not take any parameters. In other words, your declaration should be:

    public:
    	QJsonArray answerToLife() const;
    
    // Or at the very least:
    	QJsonArray answerToLife(QJsonArray array_parameter = QJsonArray()) const;
    

    That's because meta object's property() method needs to be able to call your property getter, and it has no way of knowing what argument to pass.



  • @sierdzio thanks


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.