[Qt-interest] QScript Newbie Question

Kent Hansen khansen at trolltech.com
Mon Feb 8 11:51:48 CET 2010


Alexander Carôt skrev:
> Hi all,
>
> I just started using QScript and currently work with the sample code of the documentation. In that context I have a little problem with the following code:
>
> QScriptEngine eng;
> QLineEdit *edit = new QLineEdit("",this);
> QScriptValue handler = eng.evaluate("function(text) { print('text was changed to', text); }");
> qScriptConnect(edit, SIGNAL(textChanged(const QString &)), QScriptValue(), handler);
>
> It compiles fine but whenever I change the text of the edit field nothing happens. So, my question is how I can verify the functionality that the signal reaches the script-slot ? So far I expected to have the terminal message "text was changed to ..."  or am I mistaken ?
>
> Thanks in advance,
> best

Hi,
This is due to a regression in 4.6 of the treatment of anonymous 
functions; http://bugreports.qt.nokia.com/browse/QTBUG-5757
Adding parentheses around your function expression will make the parser 
understand it.

Regards,
Kent



More information about the Qt-interest-old mailing list