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. Question regarding to software modeling..

Question regarding to software modeling..

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

    Hi, first of all, excuse me if this is not an specific Qt's question...

    I´m working with Qt5 on a desktop application using sqlite... The application basically registerers a user into DB using a GUI form.. each field accepts a QString object.

    My question is regarding to the model (or application flow).
    I´m not sure how important is to create an User class that stores all user's field:

    class User{
         QString name;
         int age;
         QString telephone;
         QString rol;
    
         //other public stuffs and member functions ahead.
    };
    

    In the form, I have the same line edit objects quantity as required.

    I have two ways to make it:

    1. Pass the data field (QStrings) to a new User, and add this user to a vector or list (to get then in order in memory). so I locally work with that vector/list and before my program finishes I copy the data into DB..

    or

    1. Pass the data field (QString) directly to DB using SQL commands (INSERT into MYTABLE.. etc...)

    What should I use? I sincerely see no sense using Nº 1... but I find it more elegant.....

    Any Tips?
    thanks.

    JonBJ 1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      Well, you could create methods that abstract how the data is fed to/from the db inside the class. That might be a way to support other destinations for this data rather than hard coding it for the database. It really depends upon what else you might do with the data.

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      1
      • U U7Development

        Hi, first of all, excuse me if this is not an specific Qt's question...

        I´m working with Qt5 on a desktop application using sqlite... The application basically registerers a user into DB using a GUI form.. each field accepts a QString object.

        My question is regarding to the model (or application flow).
        I´m not sure how important is to create an User class that stores all user's field:

        class User{
             QString name;
             int age;
             QString telephone;
             QString rol;
        
             //other public stuffs and member functions ahead.
        };
        

        In the form, I have the same line edit objects quantity as required.

        I have two ways to make it:

        1. Pass the data field (QStrings) to a new User, and add this user to a vector or list (to get then in order in memory). so I locally work with that vector/list and before my program finishes I copy the data into DB..

        or

        1. Pass the data field (QString) directly to DB using SQL commands (INSERT into MYTABLE.. etc...)

        What should I use? I sincerely see no sense using Nº 1... but I find it more elegant.....

        Any Tips?
        thanks.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        @U7Development
        Use Qt SQL model classes, https://doc.qt.io/qt-5/sql-model.html. QSqlTableModel (https://doc.qt.io/qt-5/qsqltablemodel.html) will allow you to manipulate rows, including writing them back to the database either immediately or batching up several changes. By all means declare your own classes to wrap access to the table rows/columns.

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

          Hi,

          From the looks of it, you seem to be interested in having an ORM like QxOrm. Do I understand correctly ?

          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