Hello to everybody,
I'm a newbie with QML and QT but I like it much!
I'm trying to develop a funny application which must access database, acquire data from Modbus TCP server and display it on QML page.

I'm developing different part separatly, and I've create the interface e some of back-end components, now, my problem is: how paste all into an executable?
I'm using Microsoft Win XP and Win 7 to deploy my application.

Reading QML documentation I found how create Qt Resources from QML files, so I can include them into executable to prevent errors or damage on .qml files. Now I try to create some method to update the field I inserted into QML files.

My main.qml file contains some other qml component accessed by QtResource.

My problem is: I need to expose C++ methods to QML interfaces located into QtResouces path.

I have this code:
Qt Code:
  1. class DeclarativeView : public QDeclarativeView
  2. {
  3. Q_OBJECT
  4.  
  5. public:
  6. explicit DeclarativeView(QWidget *parent = 0);
  7. ~DeclarativeView();
  8. QTimer * tim;
  9. Q_PROPERTY (double myValue READ readMyValue);
  10. double myVal;
  11. void Init();
  12. private slots:
  13. void updateValues();
  14.  
  15. };
To copy to clipboard, switch view to plain text mode 
the main element is Init function and readMyValue function
Qt Code:
  1. void DeclarativeView::Init(){
  2.  
  3. setFocusPolicy(Qt::StrongFocus);
  4. setResizeMode(QDeclarativeView::SizeRootObjectToView);
  5. setSource(QUrl("qrc:/Sezione1.qml"));
  6. rootContext()->setContextProperty("window",this);
  7. }
  8.  
  9. double DeclarativeView::readMyValue(){
  10.  
  11. return myVal;
  12. }
To copy to clipboard, switch view to plain text mode 

... but when I run my application I got this message:
qrc:/Sezione1.qml:13: ReferenceError: Can't find variable: window
How can access the rootContext from qrc environment?

Is this the right way to do this?

My objective is have only one executable which could access QML files from internal resources .qrc files, but also using Tcp Socket to acquire data and sql model to access database by C++ codes.

Thanks for your time!

Michele