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. TableView input rows strategy like invoice detail input?
QtWS25 Last Chance

TableView input rows strategy like invoice detail input?

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 3 Posters 1.2k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    You should give more details about how you setup your database access.

    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
    • MucipM Offline
      MucipM Offline
      Mucip
      wrote on last edited by
      #3

      Hi,
      My connection code like below but I do not think that this problem is about connection?

      How can I write new line to SQLite database with QSqlRelationalTableModel?

      My connection code is:

      //Burada SQLite bağlantısı kuruluyor!
                 db2 = new QSqlDatabase(QSqlDatabase::addDatabase("QSQLITE","sqlite"));
                 db2->setDatabaseName(":memory:");
                 if (!db2->open()) {
                     QMessageBox::critical(nullptr, "SQLite Veritabanına ulaşılamadı!",
                         "Veritabanına kapalı veya ulaşılamıyor!\n\n"
                                  "Program sonlanıyor.", QMessageBox::Ok);
                     return false;
                 }
      
      

      Regards,
      Mucip:)

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

        How do you setup your database ?

        Since it's an in-mermoy database, it means it won't survive between two application runs so you have to re-create all the tables each time you start your application.

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

        MucipM 1 Reply Last reply
        0
        • SGaistS SGaist

          How do you setup your database ?

          Since it's an in-mermoy database, it means it won't survive between two application runs so you have to re-create all the tables each time you start your application.

          MucipM Offline
          MucipM Offline
          Mucip
          wrote on last edited by Mucip
          #5

          Dear @SGaist,
          As I guess, It's not about db connection style.
          When I open the form I re-create or flush DB if exist.

          I want to add new line below of Tableview. Because of it connected to memory db. I insert one line to memory db and reassign qtableview to memory db.
          I think I made something wrong in this step! What is the system of add one new line to qtableview which is linked to DB?!
          This is the problem!.... :(

          I all want to do the invoice detail input like this post.

          Regards,
          Mucip:)

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

            It's not the job of the view to add new rows. Take a look at QSqlTableModel::insertRecord.

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

            MucipM 1 Reply Last reply
            0
            • SGaistS SGaist

              It's not the job of the view to add new rows. Take a look at QSqlTableModel::insertRecord.

              MucipM Offline
              MucipM Offline
              Mucip
              wrote on last edited by
              #7

              Hi @SGaist ,
              Well, what about the currentRowChanged signal on tableview? I couldn't catch it?

              Regards,
              Mucip:)

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

                This is when a row has changed, you asked for adding a new row.

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

                MucipM 2 Replies Last reply
                0
                • SGaistS SGaist

                  This is when a row has changed, you asked for adding a new row.

                  MucipM Offline
                  MucipM Offline
                  Mucip
                  wrote on last edited by
                  #9

                  Dear @SGaist ,
                  Ok. I will give up to use db connection with memory DB.
                  I will use like below
                  QStandardItemModel model(4, 2);

                  And finally I transfer theese data to DB when close form or push save button.

                  Well, Normally if you push down arrow at the end of the tableview it add one new row at the bottom. How can I get this? By which signal/slot?...

                  Regards,
                  Mucip:)

                  1 Reply Last reply
                  0
                  • SGaistS SGaist

                    This is when a row has changed, you asked for adding a new row.

                    MucipM Offline
                    MucipM Offline
                    Mucip
                    wrote on last edited by
                    #10

                    Hi, @SGaist
                    Well I changed to use QStandardItemModel.
                    But How can I delete pointer? Ofcourse I can add delete in formClose signal but where can I add "this" parameter

                    this->modelFisDetay = new QStandardItemModel(10,4);
                    

                    Normally it should be:

                    this->modelTableBelgeTip = new QSqlQueryModel(this);
                    

                    But I can not add this to QStandardItemModel???

                    Regards,
                    Mucip:)

                    mrjjM 1 Reply Last reply
                    0
                    • MucipM Mucip

                      Hi, @SGaist
                      Well I changed to use QStandardItemModel.
                      But How can I delete pointer? Ofcourse I can add delete in formClose signal but where can I add "this" parameter

                      this->modelFisDetay = new QStandardItemModel(10,4);
                      

                      Normally it should be:

                      this->modelTableBelgeTip = new QSqlQueryModel(this);
                      

                      But I can not add this to QStandardItemModel???

                      Regards,
                      Mucip:)

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      Hi
                      Yes you can :)
                      QStandardItemModel(int rows, int columns, QObject * parent = 0)
                      Parent just go last.

                      MucipM 1 Reply Last reply
                      0
                      • mrjjM mrjj

                        Hi
                        Yes you can :)
                        QStandardItemModel(int rows, int columns, QObject * parent = 0)
                        Parent just go last.

                        MucipM Offline
                        MucipM Offline
                        Mucip
                        wrote on last edited by
                        #12

                        Dear @mrjj ,
                        Great... Thanks... ;-)

                        Regards,
                        Mucip:)

                        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