Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to combine QML and SQL conveniently?
Forum Update on Monday, May 27th 2025

How to combine QML and SQL conveniently?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 1.4k Views
  • 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.
  • C Offline
    C Offline
    CoderJeff
    wrote on 8 Apr 2015, 00:49 last edited by
    #1

    I am working on a desktop program about SQL. But I find it is very inconvenient to interact with QML and SQL while it is much easier to use UI instead of QML. The examples about SQL in Qt Creator 3.3.0 are all written in either only C++ or combination of C++ and UI. I never saw SQL examples in QML and C++.

    Is QML not a good way to interact with Database?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rahul Das
      wrote on 8 Apr 2015, 05:00 last edited by Rahul Das 4 Aug 2015, 05:03
      #2

      @CoderJeff said:

      it is very inconvenient to interact with QML and SQL while it is much easier to use UI instead of QML

      Felt the same! may be because, too much used to UI than QML.
      Mean while i would like to share few links that was useful to me ..
      http://stackoverflow.com/questions/16658360/integrating-sqlite-with-qt-quick
      https://wiki.qt.io/How_to_use_a_QSqlQueryModel_in_QML
      http://wiki.qt.io/QML_and_QSqlTableModel


      Declaration of (Platform) independence.

      C 1 Reply Last reply 8 Apr 2015, 05:51
      0
      • R Rahul Das
        8 Apr 2015, 05:00

        @CoderJeff said:

        it is very inconvenient to interact with QML and SQL while it is much easier to use UI instead of QML

        Felt the same! may be because, too much used to UI than QML.
        Mean while i would like to share few links that was useful to me ..
        http://stackoverflow.com/questions/16658360/integrating-sqlite-with-qt-quick
        https://wiki.qt.io/How_to_use_a_QSqlQueryModel_in_QML
        http://wiki.qt.io/QML_and_QSqlTableModel

        C Offline
        C Offline
        CoderJeff
        wrote on 8 Apr 2015, 05:51 last edited by CoderJeff 4 Aug 2015, 06:04
        #3

        @Rahul-Das Thanks for your sharing. I also spent more time on the last two links.

        Besides, I think that the following links are also useful:
        http://doc.qt.io/qt-4.8/qtbinding.html
        http://doc.qt.io/qt-4.8/qml-integration.html

        "Keep in mind that QWidgets were designed for a different type of user interface than QML, so it is not always a good idea to port a QWidget-based application to QML. QWidgets are a better choice if your UI is comprised of a small number of complex and static elements, and QML is a better choice if your UI is comprised of a large number of simple and dynamic elements."

        "Warning: While it is possible to use C++ to access and manipulate QML objects deep into the object tree, we recommend that you do not take this approach outside of application testing and prototyping. One strength of QML and C++ integration is the ability to implement the QML user interface separately from the C++ logic and dataset backend, and this strategy breaks if the C++ side reaches deep into the QML components to manipulate them directly. This would make it difficult to, for example, swap a QML view component for another view, if the new component was missing a required objectName. It is better for the C++ implementation to know as little as possible about the QML user interface implementation and the composition of the QML object tree."

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qxorm
          wrote on 8 Apr 2015, 07:13 last edited by
          #4

          QxOrm library provides QxModelView module to interact easily between QML and database through the Qt model/view architecture.
          There is an example in the FAQ here : http://www.qxorm.com/qxorm_en/faq.html#faq_300

          1 Reply Last reply
          0

          1/4

          8 Apr 2015, 00:49

          • Login

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