December 3, 2010

kyleplattner kyleplattner
Lab Rat
242 posts

QML to .exe

Page  
1

I am trying to move from my simple QML files to a windows .exe that I can pass on to management for review. I installed the Visual Studio add-in but it looks like it wants to open a .pro file. All I have is .qml and .qmlproject. Could someone point me in the right direction of what needs done?

26 replies

December 3, 2010

blex blex
Lab Rat
191 posts

Is Qmlviewer the right tool?

 Signature 

————————————

Oleksiy Balabay

December 3, 2010

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

You can write small wrapper (I think Creator already can do it automatically, but not sure) for showing qml.

December 3, 2010

kyleplattner kyleplattner
Lab Rat
242 posts

If you could provide me with some more details of how exactly to get from the .qml files to a usable .exe, that would be helpful. Thanks,

Kyle

December 3, 2010

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

something like (not tested, just coded here in reply form)

  1. int main (int argc, char **argv)
  2. {
  3.     QApplication app(argc,argv);
  4.     QDeclarativeView view("/path/to/your/Example.qml");
  5.     view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
  6.     view.resize(500,500); //this and prev lines are needed only if you don't have sizes in root element of your qml
  7.     view.show();
  8.     return app.exec();
  9. }

December 3, 2010

kyleplattner kyleplattner
Lab Rat
242 posts

Can I compile this in any compiler?

December 3, 2010

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

I don’t think that compiler can be problem here. Just make sure you have all needed in your env variables.

December 3, 2010

kyleplattner kyleplattner
Lab Rat
242 posts

Where can I download all the environment variables? While I tried to compile, I got a QApplication undeclared error.

December 3, 2010

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

you have to include them. Sorry I forgot them.

  1. #include <QApplication>
  2. #include <QDeclarativeView>

Also don’t forget to add gui and declarative to QT var in your .pro file.

December 3, 2010

kyleplattner kyleplattner
Lab Rat
242 posts

Please excuse my ignorance but you will have to explain the last sentence you wrote. I do not have a .pro file, do I need one?

December 3, 2010

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

Yes, you need a .pro file.

December 3, 2010

kyleplattner kyleplattner
Lab Rat
242 posts

Again, forgive my beginner questions but how do I create one? What is it?

December 3, 2010

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

Save code I wrote you before as main.cpp and run in folder with it

  1. qmake -project

It will create a .pro file. Open it and find QT var. I think it will contain only

  1. QT += core gui

make it
  1. QT += core gui declarative

After it run qmake in this folder with name of .pro file as argument. And after it run make (or nmake, if you are using msvc compiler).

December 3, 2010

kyleplattner kyleplattner
Lab Rat
242 posts

I did every step up until the make command which returned:
make: *** No targets specified and no makefile found. Stop.

December 3, 2010

Denis Kormalev Denis Kormalev
Lab Rat
1654 posts

Is there Makefile file created after ?

  1. qmake yourproject.pro

December 3, 2010

kyleplattner kyleplattner
Lab Rat
242 posts

the command executes without an error, but I don’t see a makefile

Page  
1

  ‹‹ Import a javascript file from another javascript file      Can QML files be obfuscated before bundling it in a sis file ››

You must log in to post a reply. Not a member yet? Register here!