Qt World Summit: Register Today!

webengine function does not take 0 arguments

  • hello,
    I have in file .h :

    Q_PROPERTY(QJsonArray answerToLife READ answerToLife NOTIFY answerToLifeChanged)
    . . . . . 
    	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:

    	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