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. Possibilities for adding new **records** inside database
Forum Updated to NodeBB v4.3 + New Features

Possibilities for adding new **records** inside database

Scheduled Pinned Locked Moved Solved General and Desktop
sql
14 Posts 5 Posters 3.5k Views 3 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by mrjj
    #2

    Hi
    Yes you can program it.
    The QHeaderView is the class that controls the Top and side "caption" cells and
    you can connects its click signal and insert new row when index is that of star.

    1 Reply Last reply
    1
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #3
      This post is deleted!
      1 Reply Last reply
      1
      • G4banditG Offline
        G4banditG Offline
        G4bandit
        wrote on last edited by
        #4

        @mrjj said in Possibilities for adding new **records** inside database:

        you can connects its click signal and insert new row when index is that of star.

        First of all how can I display such a row inside the QTableView?

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #5

          Hi
          Its a QHeaderView
          http://doc.qt.io/qt-5/qheaderview.html
          QTableView has one for vert and one for horizontal.
          You can use stylesheet or subclass QHeaderView to make it look like like your sample.

          1 Reply Last reply
          0
          • G4banditG Offline
            G4banditG Offline
            G4bandit
            wrote on last edited by
            #6

            @mrjj

            Do we actually talk from the same stuff?

            I am not interested neither in any formating stuff nor any visualisations of a star or not.

            First thing I need is that a line with fields appear below the HorizontalHeader. The reason is to avoid a lot of QLineEdits Elements.

            mrjjM 1 Reply Last reply
            0
            • G4banditG G4bandit

              @mrjj

              Do we actually talk from the same stuff?

              I am not interested neither in any formating stuff nor any visualisations of a star or not.

              First thing I need is that a line with fields appear below the HorizontalHeader. The reason is to avoid a lot of QLineEdits Elements.

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

              @G4bandit
              Well those top and side cells that not editable are controlled by QHeaderView.
              So hence i keep talking about it.
              Buf look is not important you can ignore it for now

              If you inset empty row in your model it will show there. <if index matches)
              user can then fill it out.

              Since i dont know SSMS im not sure How it does it but it sounded like you want to click on the header at the star cell. then new empty rows comes.

              1 Reply Last reply
              0
              • G4banditG Offline
                G4banditG Offline
                G4bandit
                wrote on last edited by G4bandit
                #8

                @mrjj said in Possibilities for adding new **records** inside database:

                Since i dont know SSMS

                0_1513268895817_SSMS_DesigningMode2.png

                I just edit the last record. It is shown a Symbol as indice for editing and the data is also checked before saved finally.
                IMPORTANT: this is not that table I want to edit inside TableView. Table in pic is for showing the functionality in generall from SSMS.

                @mrjj said

                If you inset empty row in your model it will show there

                I do not really know how you mean it but I can not just insert a row because this are 3 tables joined together.
                Just thinking: maybe it is at all too hard/difficult to implement such a functionality and I should focus on edit Tbl1 than Tbl2 than Tbl3.
                But I still prefer such option like in SSMS is given.

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

                  Hi,

                  From your description you would need some sort of proxy model that would handle the "virtual row" and and the propagate the new values to each table where it makes sense.

                  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
                  • G4banditG Offline
                    G4banditG Offline
                    G4bandit
                    wrote on last edited by G4bandit
                    #10
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • G4banditG G4bandit

                      @mrjj said in Possibilities for adding new **records** inside database:

                      Since i dont know SSMS

                      0_1513268895817_SSMS_DesigningMode2.png

                      I just edit the last record. It is shown a Symbol as indice for editing and the data is also checked before saved finally.
                      IMPORTANT: this is not that table I want to edit inside TableView. Table in pic is for showing the functionality in generall from SSMS.

                      @mrjj said

                      If you inset empty row in your model it will show there

                      I do not really know how you mean it but I can not just insert a row because this are 3 tables joined together.
                      Just thinking: maybe it is at all too hard/difficult to implement such a functionality and I should focus on edit Tbl1 than Tbl2 than Tbl3.
                      But I still prefer such option like in SSMS is given.

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

                      @G4bandit said in Possibilities for adding new **records** inside database:

                      I do not really know how you mean it but I can not just insert a row because this are 3 tables joined together.
                      Just thinking: maybe it is at all too hard/difficult to implement such a functionality and I should focus on edit Tbl1 than Tbl2 than Tbl3.
                      But I still prefer such option like in SSMS is given.

                      Still not sure what you mean. If you are creating a VIEW by JOINing tables together, you cannot edit rows via the VIEW (unless it's an editable VIEW, but that's another matter, unless you say that's what you have created), even in SSMS, only view them! You can only edit rows in an actual single table.

                      1 Reply Last reply
                      0
                      • VRoninV Offline
                        VRoninV Offline
                        VRonin
                        wrote on last edited by VRonin
                        #12

                        I got very close to the solution here: https://github.com/VSRonin/InsertProxy

                        For some reason the "virtual" row/column is not editable via the view (but it works programmatically so I suspect it's just something stupid I'm not seeing). I won't be able to work on it to fix it until Monday but you are welcome to have a crack at it.

                        If you solve the problem submit a pull request please

                        EDIT

                        Code fixed now

                        JonBJ 1 Reply Last reply
                        2
                        • VRoninV VRonin

                          I got very close to the solution here: https://github.com/VSRonin/InsertProxy

                          For some reason the "virtual" row/column is not editable via the view (but it works programmatically so I suspect it's just something stupid I'm not seeing). I won't be able to work on it to fix it until Monday but you are welcome to have a crack at it.

                          If you solve the problem submit a pull request please

                          EDIT

                          Code fixed now

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

                          @VRonin
                          Did you knock that code up in your tea break? :)

                          1 Reply Last reply
                          0
                          • G4banditG Offline
                            G4banditG Offline
                            G4bandit
                            wrote on last edited by
                            #14

                            @All
                            Proxy??? Help :O

                            @JonB said in Possibilities for adding new **records** inside database:

                            Still not sure what you mean. If you are creating a VIEW by JOINing tables together, you cannot edit rows via the VIEW (unless it's an editable VIEW, but that's another matter, unless you say that's what you have created), even in SSMS, only view them! You can only edit rows in an actual single table.

                            That is correct. I can not edit the rows but like I said it is very uncomfortable to add like 20 LineEdits inside the gui to be able to edit all of my attributes from one table.
                            So for me is the best solution to desclaim the usage of 20 LineEdits and transfer such input possibility directly inside the QTableView.

                            1.Step
                            Created a view inside the SSMS with joined table etc whatever completly free. The view is not editable.

                            2.Step Qt
                            2.1When I press "Insert" than a table pops up with 1...n Attributes, whereas it corresponds to the created view inside SSMS.

                            	  TblModel->setTable(SSMSView);
                            
                                  TblModel->setEditStrategy(QSqlTableModel::OnManualSubmit);
                                  TblModel->select();
                            	  
                            	  QSqlRecord record = TblModel->record();
                                  record.setValue(TblModel->fieldIndex("Attribute1"),"*");
                                  record.setValue(TblModel->fieldIndex("Attribute2"),"*");
                                  record.setValue(TblModel->fieldIndex("Attribute3"),"*");
                                  record.setValue(TblModel->fieldIndex("Attribute4"),"*");
                                  TblModel->insertRecord(TblModel->rowCount(),record);
                            

                            Here a line is created inside the TableView where the mandatory fields are marked with *

                            Now the user makes his input by inserting data field by field inside the given row.

                            2.2When I press "Submit" than
                            ...I extract data for table 1 and perform submitAll for the selected table 1.
                            ...I ...table2 ....table2
                            and so on.

                            Challange solved.

                            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