Results 1 to 10 of 10

Thread: qt quick using c++ for the logic

  1. #1
    Join Date
    Aug 2010
    Posts
    15
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default qt quick using c++ for the logic

    Hello,

    I need to create a level editor for a videogame I am making, and I thought I could do it in qml, so I can learn it and see if I like it, but I am a bit lost, because the documentation is not so clear (in my opinion) explaining the different ways/how to integrate c++ with qml. I'd appreciate if someone points me into the right direction.

    I want to do an application that uses qml for the interface, but:

    -Uses c++ for the logic (usually it is recommended a plugin for this I think).
    -a qml element has to be loaded dynamically depending on what the c++ logic says (specifically, I load from a file the level, that is tiled, and would have to create a grid of the size that the file says). For that I found this: http://doc.qt.digia.com/qt/qdeclarat...icobjects.html and this recommends using qml bindings, what I think is a different approach than plugins, and in this case the application should be qwidget based.

    What I've tried right now is just creating the hello world application from the qt creator, it uses a c++ class called qtquick2applicationviewer to load the qml, but I am not even sure if this kind of application can do what I need (specifically point 2).

  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: qt quick using c++ for the logic

    Before you start working on this, think if QML has anything to offer for you which can't easily be done with Graphics View. If you want to load most content based on description in C++, I don't see how a declarative engine helps here.
    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. #3
    Join Date
    Aug 2010
    Posts
    15
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qt quick using c++ for the logic

    Well, I'm working on my final year project, and I thought that as I am investing a lot of hours on it, I better learn something new. Also, I thought that the idea was that qml should be now the preferred way to develop qt applications, but I'm seeing that even qt desktop components are not yet included.

  4. #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: qt quick using c++ for the logic

    If most of functionality of your application is related to dragging static objects on some canvas, setting their properties, doing things like copy & paste, undo&redo, etc. then QtQuick doesn't have much to offer in this regard. It's about DECLARING things to happen. You can't really predeclare situations that heavily depend on the logic. I'm not saying it is not possible to do what you want with QtQuick (see the link at the end of my post), I'm just saying it will probably take you much time without any real benefits.

    http://www.youtube.com/watch?v=kvWeE3kurEQ
    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.


  5. #5
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: qt quick using c++ for the logic

    To add to the complete answer done by Wysota.

    Currently I'm "forced" to go with the QML because, according to the "force beyond me", this "allows" to divide logic (c++) and GUI (done without problem with Widget approach, but live it as it is...). The actual reason is that person that is not familiar with he Qt read, on digia or something, that QML is new way of designing new desktop applications (no comments here) ... so I'm stuck with designing for 2h GUI that could be done within 10 min widget way.

    Depending on Your Qt knowledge level, transition is not so hard.

    My thoughts about QML:
    1. adds additional level of the abstraction, code more prune to the error, especially if You don't like JS/Java/JSOns style languages, QML descriptive language for the GUI. QtCreator crashed on me few times on editing QML file, and as was said here before, only primitive shapes are ready, lacking of the actual widget support atm.
    2. adds additional dependences to the project. Along with the standard libraries qtcore/gui I had to ship qdeclarativeview, sql, qscripting etc. So it's something to consider, because these additional libraries are like 10+MB in size
    3. communication between c++ and QML is fairly easy and is actually one of the strong points of that design, because You can actually really fast switch between GUI definitions, very handy if porting to the embedded device wit diffrent screen sizes - and to point here out, QML was designed for the embedded devices in mind

    Some people say that rule is: animated GUI -> QML, statical GUI -> Widgets. I must disagree, because I did develop a game,using custom widgets, that run in FullHD at 60fps without any problem. The same goes for the custom widgets - no problem at all and they look nice (i.e. web 2.0 look like) - but that is entirely up to programmer/designer.

    At the end I must say that QML, IMHO, is not something to be considered for developing widget rich applications (i.e. level editor - although, as was said by Wysota before, this can be done). If You want to design custom components for, practically every, widget then it's a good way to go.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  6. #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: qt quick using c++ for the logic

    Quote Originally Posted by Talei View Post
    Currently I'm "forced" to go with the QML because, according to the "force beyond me", this "allows" to divide logic (c++) and GUI (done without problem with Widget approach, but live it as it is...). The actual reason is that person that is not familiar with he Qt read, on digia or something, that QML is new way of designing new desktop applications (no comments here) ... so I'm stuck with designing for 2h GUI that could be done within 10 min widget way.
    There is a simple way to use both QML and widgets And I'm not speaking about Qt Desktop Components. So you could "cheat" your management by going that route
    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.


  7. #7
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: qt quick using c++ for the logic

    @Wysota
    Can You shed some more light on that matter .
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  8. #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: qt quick using c++ for the logic

    Quote Originally Posted by Talei View Post
    @Wysota
    Can You shed some more light on that matter .
    You can implement a wrapper over widgets for QML so that you can use widgets in QML (as opposed to C++) without using QtQuick, e.g.:

    javascript Code:
    1. Widget {
    2. HLayout {
    3. PushButton {
    4. text: "Button 1"
    5. onClicked: { ... }
    6. }
    7. PushButton { }
    8. PushButton { }
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 

    etc.
    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.


  9. #9
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qt quick using c++ for the logic

    Quote Originally Posted by wysota View Post
    You can implement a wrapper over widgets for QML so that you can use widgets in QML (as opposed to C++) without using QtQuick, e.g.:
    As demonstrated by Thomas McGuire at this year's Qt Developer Days
    http://www.youtube.com/watch?v=NtXSaYpqaSQ (beginning around 16:30)

    Cheers,
    _

  10. The following user says thank you to anda_skoa for this useful post:

    Talei (17th January 2013)

  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: qt quick using c++ for the logic

    Yes, exactly
    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. The following user says thank you to wysota for this useful post:

    Talei (17th January 2013)

Similar Threads

  1. qtsoap.h is lost
    By saimel in forum Qt Programming
    Replies: 4
    Last Post: 25th September 2012, 23:41
  2. Lost events.
    By chris_helloworld in forum Qt Programming
    Replies: 5
    Last Post: 15th September 2010, 15:36
  3. Completely lost!!!
    By Zuks in forum Newbie
    Replies: 4
    Last Post: 2nd December 2009, 10:58
  4. lost signals ?
    By deepinlife in forum Qt Programming
    Replies: 3
    Last Post: 17th June 2008, 11:11
  5. Lost widget
    By anli in forum Qt Programming
    Replies: 6
    Last Post: 29th July 2006, 20:02

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.