[Qt-interest] QScript Newbie Question

"Alexander Carôt" alexander_carot at gmx.net
Mon Feb 8 15:16:06 CET 2010


Hi Sean,

this was good hint ! I didn't get how you can access the line edit without attaching it to a GUI widget, which is why I modified the code in such way:

#include <QApplication>
#include <QDebug>
#include <QLineEdit>
#include <QScriptEngine>
#include <QWidget>

int main( int argc, char* argv[] ){
  QApplication app( argc, argv );
  QWidget *GUI = new QWidget();
  GUI->setGeometry(50,50,300,300);
  GUI->show();

  QLineEdit* edit = new QLineEdit(GUI);
  edit->setGeometry( 0, 0, 150, 23 );
  edit->show();

  QScriptEngine engine;
  QScriptValue handler = engine.evaluate( "(function myFunc( text ) { print('Text changed to:', text ); })" );
  qScriptConnect( edit, SIGNAL( textChanged( const QString& ) ),QScriptValue(), handler );
  qDebug() << handler.toString();  

  return app.exec();
}

and eventually it worked out. So - with respect to my problem I need to figure some more details and dependencies first before I will get back.

Thanks a lot ! It really helped.

Talk to you,
Best regards

-- A l e x




-- 
Dr.-Ing. Alexander Carôt
Email : Alexander at Carot.de
Tel.: +49 (0)177 5719797



Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3.5 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/atbrowser



More information about the Qt-interest-old mailing list