Results 1 to 20 of 20

Thread: how to convert qml to exe?

  1. #1
    Join Date
    Jun 2009
    Posts
    74
    Thanks
    23
    Thanked 2 Times in 2 Posts

    Default how to convert qml to exe?

    Hi All,

    I write a simple qml file, I can use it whith qmlviewer,but how can I compile it
    to a executable binary file?


    Thanks advance for your help!

    Best regards,
    hb

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to convert qml to exe?

    Create a view for your file, wrap it all into main() and run it.
    Qt Code:
    1. int main(int argc, char **argv){
    2. QApplication app(argc, argv);
    3. QDeclarativeView view;
    4. view.setSource(QUrl::fromLocalFile("myqmlfile.qml"));
    5. view.show();
    6. return app.exec();
    7. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    hashb (25th September 2010)

  4. #3
    Join Date
    Nov 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to convert qml to exe?

    I dont know why, but that isnt working for me...
    when I run the exe file I get the following messages:

    "Qwidget: Must construct a QApplication before a QPaintDevice

    This application has requested the Runtime to terminate it in an unusual way.
    Please contact the application's support team for more information."

    and the .exe file stopped working...

    any ideas?

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to convert qml to exe?

    The idea is your code is different than mine. You have some global object that is a paint device and that's forbidden.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #5
    Join Date
    Nov 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to convert qml to exe?

    Damn this qt things are too complicated! (for begginers of course (like me)).
    The code im trying to compile is this:

    #include <QtGui/QApplication>
    #include <QtDeclarative/QDeclarativeView>
    #include <QtDeclarative/QDeclarativeContext>

    int main(int argc, char **argv){
    QApplication app(argc, argv);

    QDeclarativeView *view = new QDeclarativeView();
    view->setSource(QUrl::fromLocalFile("main.qml"));
    view->show();

    return app.exec();
    }

    and I have the main.qml that is one of the tutorial's guide:

    import Qt 4.7

    Rectangle {
    width: 300
    height: 300

    color: backgroundColor

    Text {
    anchors.centerIn: parent
    text: "Hello Yellow World!"
    }
    }

    and the error occurs. And its not because of the view pointer...
    I first tried your way and then copied this code from qt's tutorial guides...

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to convert qml to exe?

    Is this really the whole code you have?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #7
    Join Date
    Nov 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to convert qml to exe?

    yup. And my qt version is 4.7.0 ...
    Last edited by fervenceslau; 6th November 2010 at 20:38.

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to convert qml to exe?

    This code is correct and it works for me. Check your project file for any additional files you might have there.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #9
    Join Date
    Nov 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to convert qml to exe?

    #-------------------------------------------------
    #
    # Project created by QtCreator 2010-11-06T17:38:54
    #
    #-------------------------------------------------

    QT += core

    QT -= gui

    TARGET = Teste
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app

    SOURCES += main.cpp

    LIBS += -lQtDeclaratived4


    =/

  11. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to convert qml to exe?

    What if you remove the LIBS line and add this instead (I doubt it will change anything but will be more correct anyway):
    qmake Code:
    1. QT+=declarative
    To copy to clipboard, switch view to plain text mode 

    Oh, I see what's wrong. You have a "QT-=gui" line, remove it. Your code shouldn't even build with it there, you must have moved your includes to some weird place so that the compiler can see them.

    The project file should look like this:
    qmake Code:
    1. TARGET=Teste
    2. SOURCES += main.cpp
    3. QT += declarative
    4. CONFIG += app_bundle
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #11
    Join Date
    Nov 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to convert qml to exe?

    Same problem even altering the .pro file...

    Whats the procedure to compile with QtCreator?
    Maybe im doing something wrong?


    Added after 34 minutes:


    Funny... I pressed the 'run qmake' thing and now when I try to compile i get these errors:

    c:\Qt\2010.05\qt\lib/libqtmaind.a(qtmain_win.o):: In function `WinMain@16':
    C:\qt-greenhouse\Trolltech\Code_less_create_more\Trollte ch\Code_less_create_more\Troll\4.6\qt\src\winmain/qtmain_win.cpp:93: error: undefined reference to `_Unwind_Resume'
    C:\qt-greenhouse\Trolltech\Code_less_create_more\Trollte ch\Code_less_create_more\Troll\4.6\qt\src\winmain/qtmain_win.cpp:135: error: undefined reference to `_Unwind_Resume'
    error: collect2: ld returned 1 exit status


    Qt is so full of bugs....
    Last edited by fervenceslau; 6th November 2010 at 21:48.

  13. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to convert qml to exe?

    It's not a bug in Qt, you know... You're obviously doing something wrong.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  14. #13
    Join Date
    Nov 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to convert qml to exe?

    Qt has a lot of issues with windows... I read in a lot of forums about the errors when trying to compile qt programs with dos, and its the same error...

    everyone says its something about the g++ compiler... but in the end no one solve this problem... It kinda sucks and makes us give up qt programing...

    And yes, I may be doing something wrong, but the code is right. The problem may be while compiling the code or something... Ill never figure it out and no one will ever solve this, thats whats going to happen uehuehue.

  15. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to convert qml to exe?

    Somehow I never have any serious problems with Qt on Windows. Maybe the packages I download are less buggy than the ones you download. But then I'm not pressing buttons randomly to see what happens. I'm still convinced you (as a human) messed up your installation yourself.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  16. #15
    Join Date
    Nov 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to convert qml to exe?

    Good thing you dont press random buttons, care sharing any info on that?

  17. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to convert qml to exe?

    Quote Originally Posted by fervenceslau View Post
    Good thing you dont press random buttons, care sharing any info on that?
    Here is the info: http://doc.qt.nokia.com. Read it all a couple of times. It's not 'matrix', I can't transfer all I know to you in a blink of an eye.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  18. #17
    Join Date
    Nov 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to convert qml to exe?

    Gee that is rough. All I need is a free-problems compiler =/...
    I dont have the time to read all that, maybe ill use my vacation time doing that...

  19. #18
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to convert qml to exe?

    Quote Originally Posted by fervenceslau View Post
    All I need is a free-problems compiler =/...
    You're not having a problem with the compiler. Analyze the two different situations you had here and ask yourself whether a compiler might have caused it (especially the sole fact that some code compiles even when it shouldn't and then you press some button and something totally different happens). Provided you know how compilers work but I'm assuming you do.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  20. #19
    Join Date
    Nov 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to convert qml to exe?

    I think i got it working...
    But i have to ask: What happens when i put two paths in the environment variables that has mingw on them, this could lead to problems latter, right?

    I reinstalled qt due to some problems trying to compile it with source, and then i realized that i had a path that had an older version of mingw.
    I removed it and apparently its working...

    The thing about graphic programming is that its hard to learn when you're new to it. And the logic behind the program you wanna make is easier to program.
    Thats whats most annoying about it.

    Anyway, ill keep digging more from nokia's reference and see what else i can learn...
    Thx for all your help (and i know your already tired of me hehe)

  21. #20
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to convert qml to exe?

    Quote Originally Posted by fervenceslau View Post
    But i have to ask: What happens when i put two paths in the environment variables that has mingw on them, this could lead to problems latter, right?
    It could lead to problems, yes. The first toolchain in path will be used but if there is something missing in it, some subset of the other installation can be used.

    The thing about graphic programming is that its hard to learn when you're new to it. And the logic behind the program you wanna make is easier to program.
    By "graphic programming" you mean a graphical user interface? You have to start thinking "asynchronous", that's true. With text-based code you usually have a linear execution flow.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Convert Pdf to Txt
    By henriquez0 in forum Qt Programming
    Replies: 3
    Last Post: 21st December 2015, 19:54
  2. how to convert an int to QByteArray
    By babu198649 in forum Qt Programming
    Replies: 12
    Last Post: 19th September 2014, 09:47
  3. How to convert XML+XSL to PDF in QT4.5
    By richardander in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2009, 23:14
  4. how to convert a xml + xsl to PDF in Qt4.4.3
    By richardander in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2009, 11:01
  5. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 17:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.