Results 1 to 10 of 10

Thread: implement c++ in qml

  1. #1
    Join Date
    Sep 2013
    Posts
    9
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default implement c++ in qml

    Hi!! I´m newer in qml and I like to implement c++ in qml, for example: when I press the rectangle or other thing ask two number and do sum. Can someone help me? Can do a complete example and give me the code please?

    thank you very much.

  2. #2
    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: implement c++ in qml

    Could you rephrase your question please?

    What is it that you want to do in QML and what is it that you want to do in C++?

    Cheers,
    _

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

    askatuak (17th September 2013)

  4. #3
    Join Date
    Sep 2013
    Posts
    9
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: implement c++ in qml

    Hi!! Cheers.

    for example, I like to do this, when I press the qml rectangle, say "Hellow World", but the "Hellow wolrd" program in c++. Other example, when I press the qml rectangle, appeared the result of 2+2 (or other numbers).

    Thanks

  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: implement c++ in qml

    He wants to call a c++ function as a result of interaction with QML-created elements.
    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. The following user says thank you to wysota for this useful post:

    askatuak (17th September 2013)

  7. #5
    Join Date
    Sep 2013
    Posts
    9
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: implement c++ in qml

    Quote Originally Posted by wysota View Post
    He wants to call a c++ function as a result of interaction with QML-created elements.
    Yes!! I like all the program because I don´t know how to do that. Thanks for all!!

  8. #6
    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: implement c++ in qml

    http://qt-project.org/doc/qt-4.8/qtb...qml-components

    Second example (the one with the ApplicationData class)

    Cheers,
    _

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

    askatuak (17th September 2013)

  10. #7
    Join Date
    Sep 2013
    Posts
    9
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: implement c++ in qml

    Quote Originally Posted by anda_skoa View Post
    http://qt-project.org/doc/qt-4.8/qtb...qml-components

    Second example (the one with the ApplicationData class)

    Cheers,
    _
    Thanks!! This example I did it, but didn´t work well. If someone can do it a easily example and give me, he would me do a big favor. I have read all about c++ class implements in qml, and I try anyway, but not work!! ah!!!

    Thanks for all!!

  11. #8
    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: implement c++ in qml

    What didn't work?

    The example contains all important pieces:
    - definition of a QObject derived class
    - marking a method as Q_INVOKABLE
    - creating an instance of that class
    - exporting it to QML by calling setContextProperty() on the view's root context.

    It doesn't get easier than that.

    If you want to use QtQuick2 instead of QtQuick1 use a QQuickView instead of the QDeclarativeView, and "import QtQuick 2.0" instead of "import QtQuick 1.1"

    Cheers,
    _

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

    askatuak (17th September 2013)

  13. #9
    Join Date
    Sep 2013
    Posts
    9
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: implement c++ in qml

    Thanks!!! the program works!!!


    Added after 38 minutes:


    How can I do, when I do fuction onclicked appered "Hellor world", but "Hellow wolrd" is in c++, for example:

    onclicked: {
    s.getstring()
    }

    onclicked:{
    text: s.getstring()
    }

    text {

    text:s.getstring()
    }
    onclicked:{
    Text.visible=s.getstring()
    }

    All that thing are proved in code but they are not run. How can I do it?

    Thanks!!!
    Last edited by askatuak; 17th September 2013 at 15:59.

  14. #10
    Join Date
    Sep 2013
    Posts
    2
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: implement c++ in qml

    I press the qml rectangle.
    These are instead travesties, misuses and abuses of the erotic lingerie's God-honoring purpose in life.

Similar Threads

  1. what is the best way to implement ?
    By david_itay in forum Newbie
    Replies: 1
    Last Post: 8th August 2012, 23:10
  2. Trying to implement QMainWindow...
    By winston2020 in forum Qt Programming
    Replies: 2
    Last Post: 23rd October 2008, 20:12
  3. how to implement this widget
    By pencilren in forum Qt Programming
    Replies: 2
    Last Post: 15th June 2007, 12:10
  4. What's the best way to implement a MainWindow
    By darkadept in forum Qt Programming
    Replies: 5
    Last Post: 5th February 2007, 18:46
  5. how to implement it ?
    By qtopiahooo in forum Qt Programming
    Replies: 3
    Last Post: 25th October 2006, 18:01

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.