Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Are there any samples or documentation on coding a Qt Quick application using C++?
Forum Updated to NodeBB v4.3 + New Features

Are there any samples or documentation on coding a Qt Quick application using C++?

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 3 Posters 887 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SamarAbdelsayed
    wrote on last edited by
    #1

    Hi,

    I'm looking for sample applications for building a "Qt Quick" application with the UI written in C++ (versus QML which is more popular). Anyone has any insight into how to use QT Quick Controls directly from C++, preferably with references to sample projects and/or documentation?

    Thanks!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Something's not quiet clear here. Do you want to build the whole UI from QML elements but generated in C++ ?

      Or if you're not interested in QML why not use the widget module ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        QutWizard
        wrote on last edited by
        #3

        The texteditor example that ships with the SDK shows you how to do this, basically you register your C++ back end like:
        @
        qmlRegisterType<DocumentHandler>("org.qtproject.example", 1, 0, "DocumentHandler");
        @

        Then derive your class from QObject, and use Q_PROPERTY:
        @
        Q_PROPERTY(QQuickItem *target READ target WRITE setTarget NOTIFY targetChanged)
        @

        To access the code from QML.

        There are other methods of doing this, but this one is how they coded this example.

        "Interacting with QML Objects from C++":http://qt-project.org/doc/qt-5/qtqml-cppintegration-interactqmlfromcpp.html

        "Exposing Attributes of C++ Types to QML":http://qt-project.org/doc/qt-5/qtqml-cppintegration-exposecppattributes.html

        What method is best practice or will be the latest and longest supported method is what I would like to know, the lack of documentation and examples is not helping matters much.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved