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. Changing design for Qt SQL class
QtWS25 Last Chance

Changing design for Qt SQL class

Scheduled Pinned Locked Moved Solved General and Desktop
qt5qtsqldatabase driverqtqml
6 Posts 3 Posters 1.9k 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.
  • M Offline
    M Offline
    maydin
    wrote on 19 Sept 2017, 22:54 last edited by
    #1

    I created a program that gets the information from database driver and shows in ListVew.

    I created my models by inheriting QSqlTableModel class. And I setup my database connections like this:

    QSqlDatabase database = QSqlDatabase::database();
    database = QSqlDatabase::addDatabase("QSQLITE");
    

    My program is for Android and therefore it uses a .sqlite file to store data.

    I need to change my program to run online. I just want to learn best option here.

    Using different DB driver like Postgres but I am not sure it works in Android application.

    TLDR: How can I make the program in tutorial online: https://doc.qt.io/qt-5/qtquickcontrols2-chattutorial-example.html

    J 2 Replies Last reply 20 Sept 2017, 06:44
    0
    • M maydin
      19 Sept 2017, 22:54

      I created a program that gets the information from database driver and shows in ListVew.

      I created my models by inheriting QSqlTableModel class. And I setup my database connections like this:

      QSqlDatabase database = QSqlDatabase::database();
      database = QSqlDatabase::addDatabase("QSQLITE");
      

      My program is for Android and therefore it uses a .sqlite file to store data.

      I need to change my program to run online. I just want to learn best option here.

      Using different DB driver like Postgres but I am not sure it works in Android application.

      TLDR: How can I make the program in tutorial online: https://doc.qt.io/qt-5/qtquickcontrols2-chattutorial-example.html

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 20 Sept 2017, 06:44 last edited by
      #2

      @maydin said in Changing design for Qt SQL class:

      I need to change my program to run online

      What does this mean?
      Do you mean you want to connect to a remote database?
      If so, then you should not do it directly as exposing databases to the Internet is a bad idea.
      What is usually done is to have a REST API for example which hides the database. Apps then use this API without directly connecting to the database.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • M maydin
        19 Sept 2017, 22:54

        I created a program that gets the information from database driver and shows in ListVew.

        I created my models by inheriting QSqlTableModel class. And I setup my database connections like this:

        QSqlDatabase database = QSqlDatabase::database();
        database = QSqlDatabase::addDatabase("QSQLITE");
        

        My program is for Android and therefore it uses a .sqlite file to store data.

        I need to change my program to run online. I just want to learn best option here.

        Using different DB driver like Postgres but I am not sure it works in Android application.

        TLDR: How can I make the program in tutorial online: https://doc.qt.io/qt-5/qtquickcontrols2-chattutorial-example.html

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 20 Sept 2017, 06:45 last edited by
        #3

        @maydin said in Changing design for Qt SQL class:

        How can I make the program in tutorial online: https://doc.qt.io/qt-5/qtquickcontrols2-chattutorial-example.html

        Well, you follow the tutorial. Do you have any specific problems with it?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        M 1 Reply Last reply 20 Sept 2017, 08:18
        0
        • J jsulm
          20 Sept 2017, 06:45

          @maydin said in Changing design for Qt SQL class:

          How can I make the program in tutorial online: https://doc.qt.io/qt-5/qtquickcontrols2-chattutorial-example.html

          Well, you follow the tutorial. Do you have any specific problems with it?

          M Offline
          M Offline
          maydin
          wrote on 20 Sept 2017, 08:18 last edited by
          #4

          @jsulm No, I do not have any problem with tutorial.

          I can connect to a remote database because I connect to it in LAN only via WiFi, not exposed to Internet. This might be bad but enough for me.

          So, can I connecto to remote DB from my Android App directly? If yes, what should I do? I have knowledge about DB management systems but IDK how they can be included in APK file.

          J 1 Reply Last reply 20 Sept 2017, 08:22
          0
          • M maydin
            20 Sept 2017, 08:18

            @jsulm No, I do not have any problem with tutorial.

            I can connect to a remote database because I connect to it in LAN only via WiFi, not exposed to Internet. This might be bad but enough for me.

            So, can I connecto to remote DB from my Android App directly? If yes, what should I do? I have knowledge about DB management systems but IDK how they can be included in APK file.

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 20 Sept 2017, 08:22 last edited by
            #5

            @maydin It should be possible to connect from Android. What to do depends on the used database: you need a correct connection string.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 20 Sept 2017, 09:39 last edited by SGaist
              #6

              Hi,

              If you want to use remote database systems like PostgreSQL or MySQL, you'll have to do some work first because neither of these provide native Android build of their package.

              For PostgreSQL, there's a wiki article here.
              For MySQL, there's a wiki article here.

              As @jsulm already noted, it's usually a bad idea to design an application which access a database directly through an open network so take care to secure the connections appropriately using encryption.

              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
              2

              1/6

              19 Sept 2017, 22:54

              • Login

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