How to make the qml executable in windows?



  • Hello guys,Would you please tell me How can I make a working .exe program with Qt Quick.
    I'm using Qt5 with Visual studio 2010, So which project should I choose (Qt quick 2 application or Qt quick2 UI or what?)



  • I'm not use Visual studio, but Qt quick 2 application should create executable for Desktop.



  • Yes, Qt quick 2 application does create .exe file if I build it as a release, but the .exe file doesn't work even after putting the required .dll files in the same folder with the .exe file, and this is what panics me :(
    Don't know what to do, any help?



  • You mean dosen't start at all or app starts but with empty window?
    In first case what the error message?
    In second case check *.qml files locations in main.cpp and place them in same directory near *.exe.
    Or insert qml files in resource file.



  • There is no error, I just run the *.exe file but it shows nothing.
    I tried it with Qt4.8 before installing Qt5, and it did open an empty window, but now it shows nothing.
    Would you please tell me exactly how to insert the *.qml file in the resources,My be I'm doing something wrong.
    -I'm not adding any extra *.qml files I just want to run the ready made hello world, from the exe.
    Thanks



  • Any help???



  • Could you please paste the code of your main.cpp?



  • Here is the code

    @#include <QtGui/QGuiApplication>
    #include "qtquick2applicationviewer.h"

    int main(int argc, char *argv[])
    {
    QGuiApplication app(argc, argv);

    QtQuick2ApplicationViewer viewer;
    viewer.setMainQmlFile&#40;QStringLiteral("qml/asdfasdf/main.qml"&#41;&#41;;
    viewer.showExpanded();
    
    return app.exec&#40;&#41;;
    

    }
    @

    this code is without adding a resource file



  • The previous code is without adding any thing in the resources



  • And here is the main.cpp after adding the resource file
    @#include <QtGui/QGuiApplication>
    #include "qtquick2applicationviewer.h"

    int main(int argc, char *argv[])
    {
    QGuiApplication app(argc, argv);

    QtQuick2ApplicationViewer viewer;
    viewer.setMainQmlFile&#40;QStringLiteral(":qml/asdfasdf/main.qml"&#41;);
    viewer.showExpanded();
    
    return app.exec();
    

    }
    @



  • When I add the resources It and run the project in Qt creator, it shows me empty window



  • !http://imageshack.us/photo/my-images/853/49026492.jpg/(photo)!

    here is a photo for the resource file, and for the project hierarchic

    This is link for the photo if it didn't appear
    http://imageshack.us/photo/my-images/853/49026492.jpg/



  • Try changing line:
    @
    viewer.setMainQmlFile(QStringLiteral(":qml/asdfasdf/main.qml"));
    @

    to
    @
    viewer.setMainQmlFile(QStringLiteral(QUrl("qrc:///Here/qml/asdfasdf/main.qml")));
    @

    And paste log from qtcreator



  • It shows lots of errors

    17:11:52: Running steps for project asdfasdf...
    17:11:52: Configuration unchanged, skipping qmake step.
    17:11:52: Starting: "C:\Qt\Qt5.0.0\Tools\QtCreator\bin\jom.exe"
    C:\Qt\Qt5.0.0\Tools\QtCreator\bin\jom.exe -f Makefile.Release
    cl -c -nologo -Zm200 -Zc:wchar_t -O2 -MD -GR -W3 -w34100 -w34189 -EHsc -DUNICODE -DWIN32 -DQT_NO_DEBUG -DQT_QUICK_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -I"..\asdfasdf\qtquick2applicationviewer" -I"........\Qt\Qt5.0.0\5.0.0\msvc2010\include" -I"........\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtQuick" -I"........\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtQml" -I"........\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtNetwork" -I"........\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtGui" -I"........\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtCore" -I"release" -I"." -I"........\Qt\Qt5.0.0\5.0.0\msvc2010\mkspecs\win32-msvc2010" -Forelease\ @C:\Users\FBM\AppData\Local\Temp\main.obj.2632.16.jom
    Copying application data...
    1 File(s) copied
    main.cpp
    Copying application data...
    1 File(s) copied
    ..\asdfasdf\main.cpp(10) : error C2070: ''unknown-type'': illegal sizeof operand
    ..\asdfasdf\main.cpp(10) : error C3861: 'LQUrl': identifier not found
    ........\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtCore/qstring.h(193) : warning C4200: nonstandard extension used : zero-sized array in struct/union
    Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array
    ..\asdfasdf\main.cpp(10) : see reference to class template instantiation 'QStaticStringData<N>' being compiled
    with
    [
    N=-1
    ]
    ..\asdfasdf\main.cpp(10) : error C3861: 'LQUrl': identifier not found
    ..\asdfasdf\main.cpp(10) : error C2070: ''unknown-type'': illegal sizeof operand
    ..\asdfasdf\main.cpp(10) : error C3861: 'LQUrl': identifier not found
    ..\asdfasdf\main.cpp(10) : error C3861: 'LQUrl': identifier not found
    jom: C:\Users\FBM\Desktop\asdfasdf-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Release\Makefile.Release [release\main.obj] Error 2
    jom: C:\Users\FBM\Desktop\asdfasdf-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Release\Makefile [release] Error 2
    17:11:53: The process "C:\Qt\Qt5.0.0\Tools\QtCreator\bin\jom.exe" exited with code 2.
    Error while building/deploying project asdfasdf (kit: Desktop Qt 5.0.0 MSVC2010 32bit (SDK))
    When executing step 'Make'



  • Ehh sorry,
    Y must include QUrl header in top of main.cpp
    @
    #include <QUrl>
    @

    and try again



  • I included it and looks like I got the same errors

    20:37:14: Running steps for project asdfasdf...
    20:37:14: Configuration unchanged, skipping qmake step.
    20:37:14: Starting: "C:\Qt\Qt5.0.0\Tools\QtCreator\bin\jom.exe"
    C:\Qt\Qt5.0.0\Tools\QtCreator\bin\jom.exe -f Makefile.Release
    cl -c -nologo -Zm200 -Zc:wchar_t -O2 -MD -GR -W3 -w34100 -w34189 -EHsc -DUNICODE -DWIN32 -DQT_NO_DEBUG -DQT_QUICK_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_OPENGL_ES_2 -DQT_OPENGL_ES_2_ANGLE -I"..\asdfasdf\qtquick2applicationviewer" -I"........\Qt\Qt5.0.0\5.0.0\msvc2010\include" -I"........\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtQuick" -I"........\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtQml" -I"........\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtNetwork" -I"........\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtGui" -I"........\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtCore" -I"release" -I"." -I"........\Qt\Qt5.0.0\5.0.0\msvc2010\mkspecs\win32-msvc2010" -Forelease\ @C:\Users\FBM\AppData\Local\Temp\main.obj.2568.15.jom
    main.cpp
    Copying application data...
    1 File(s) copied
    Copying application data...
    1 File(s) copied
    ..\asdfasdf\main.cpp(10) : error C2070: ''unknown-type'': illegal sizeof operand
    ..\asdfasdf\main.cpp(10) : error C3861: 'LQUrl': identifier not found
    ........\Qt\Qt5.0.0\5.0.0\msvc2010\include\QtCore/qstring.h(193) : warning C4200: nonstandard extension used : zero-sized array in struct/union
    Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array
    ..\asdfasdf\main.cpp(10) : see reference to class template instantiation 'QStaticStringData<N>' being compiled
    with
    [
    N=-1
    ]
    ..\asdfasdf\main.cpp(10) : error C3861: 'LQUrl': identifier not found
    ..\asdfasdf\main.cpp(10) : error C2070: ''unknown-type'': illegal sizeof operand
    ..\asdfasdf\main.cpp(10) : error C3861: 'LQUrl': identifier not found
    ..\asdfasdf\main.cpp(10) : error C3861: 'LQUrl': identifier not found
    jom: C:\Users\FBM\Desktop\asdfasdf-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Release\Makefile.Release [release\main.obj] Error 2
    jom: C:\Users\FBM\Desktop\asdfasdf-build-Desktop_Qt_5_0_0_MSVC2010_32bit_SDK-Release\Makefile [release] Error 2
    20:37:17: The process "C:\Qt\Qt5.0.0\Tools\QtCreator\bin\jom.exe" exited with code 2.
    Error while building/deploying project asdfasdf (kit: Desktop Qt 5.0.0 MSVC2010 32bit (SDK))
    When executing step 'Make'



  • I think that you didn't recompile project or did not add QUrl include because error:
    ..\asdfasdf\main.cpp(10) : error C2070: ‘‘unknown-type’‘: illegal sizeof operand
    ..\asdfasdf\main.cpp(10) : error C3861: ‘LQUrl’: identifier not found

    Is still the same (the same line). If you added #include <QUrl> then error line would be 11 not 10.

    Try to add #include <QUrl> and clean and rebuild projects.

    I must say that i didn't use MS compiler for a couple of years and did not remeber complator errors but it's clearly looks like it doesn't have QUrl header.



  • I did include the <QUrl> , but the reason of the error being in the same line (10), is that I had an empty line between the headers and the main, So I just put the <QUrl> on it :)



  • HURRAH, It might be a temporary solution, but I figured it out.
    I copied all the *.dll files in the this directory C:\Qt\Qt5.0.1\5.0.1\msvc2010\bin and paste it in the same folder with my *.exe file and it worked.
    The next step is to remove one file at a time and run the *.exe after every remove till I figure which files exactly the app needs.

    @tolszak Thank you very much for your help :)
    @qxoz Thank you very much for your help too :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.