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. Universal return from SQLite to QML. How?
QtWS25 Last Chance

Universal return from SQLite to QML. How?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 455 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.
  • B Offline
    B Offline
    bogong
    wrote on last edited by
    #1

    Hello all!

    In this example the interaction between SQLite and QML via defining data model/roles hardly in listmodel.cpp:

    QHash<int, QByteArray> ListModel::roleNames() const {
    
    	QHash<int, QByteArray> roles;
    	roles[IdRole] = "id";
    	roles[FNameRole] = "fname";
    	roles[SNameRole] = "sname";
    	roles[NikRole] = "nik";
    	return roles;
    }
    

    Is there any way to return the data like array independently of data structure. And handling data in QML/Js without defining it in CPP? If there 5 fields in DB row - then return array within 5 elements, if there 10 fields in row then return array of 10 elements. I need to create tables dynamically on runtime and perform CRUD (Create/Read/Update/Delete) operations.

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

      Hi,

      Do you have some kind of REST service in mind ?

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

      B 1 Reply Last reply
      -1
      • SGaistS SGaist

        Hi,

        Do you have some kind of REST service in mind ?

        B Offline
        B Offline
        bogong
        wrote on last edited by
        #3

        @SGaist Do you have any suggestion for the matter of this topic? How REST might be connected to the topic? CRUD is only acronym that mean operations ability not only for REST API.

        For now I am seeking solution to perform the line:

        direct schema: [something from SQL query based on Sqlite] ->> QVariantList ->> JS Array in QML
        reverse schema: JS Array in QML ->> QVariantList ->> [something to SQL query based on Sqlite]

        The question about "something from/to SQL query based on Sqlite" where I don't need to be hardcoded the data model. I need to do it dynamically. I shouldn't care about data model on CPP level only in QML/JS, just passing query result as-it-is into QML like JS Array. Nothing more.

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

          I know what CRUD means. Lately I've encountered it more in the context of web service than anything else, hence my question.

          From the looks of it, you seem to want to write some sort of alternative to phpMyAdmin in QML. Is that the case ?

          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
          -1

          • Login

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