Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Creating a table with grid view adding, editing and deleting data from the MS SQL server using Qt Creator
Forum Updated to NodeBB v4.3 + New Features

Creating a table with grid view adding, editing and deleting data from the MS SQL server using Qt Creator

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
29 Posts 4 Posters 13.9k Views 2 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.
  • V Offline
    V Offline
    veera
    wrote on 7 Mar 2017, 05:15 last edited by
    #4

    where i will get the examples of the Qt grid view adding ,editing and deleting data from the MS Sql server....... i am already done the adding and editing the data from the MS Sql server using Qtableview and QTablewidget now i am trying to do using grid view as similar as C#..........

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 7 Mar 2017, 08:50 last edited by
      #5

      Do you mean something like this list in the QtSql module example page ?

      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
      • V Offline
        V Offline
        veera
        wrote on 7 Mar 2017, 09:14 last edited by
        #6

        No ...i have seen this link already but i did not understand ...you guide me how should i start grid view on qt creator using MS sql server ......

        M 1 Reply Last reply 7 Mar 2017, 09:32
        0
        • V veera
          7 Mar 2017, 09:14

          No ...i have seen this link already but i did not understand ...you guide me how should i start grid view on qt creator using MS sql server ......

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 7 Mar 2017, 09:32 last edited by
          #7

          @veera
          Hi
          What is a Qt Grid View ?
          Unlike QTableview and QTablewidget,
          i do not know what class you mean when you say " Qt grid view" :)

          1 Reply Last reply
          0
          • V Offline
            V Offline
            veera
            wrote on 7 Mar 2017, 09:42 last edited by
            #8

            On the single window itself we can put add ,delete,edit the MS Sql table data using grid view as similar like C# they are using grid view for the same ...i am looking for the same thing need to implement......

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 7 Mar 2017, 10:06 last edited by
              #9

              Just to be sure we're on the same page, Qt Creator is an IDE, not a database editor so you are trying to build an database interface application, correct ?

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

              V 1 Reply Last reply 7 Mar 2017, 10:45
              0
              • S SGaist
                7 Mar 2017, 10:06

                Just to be sure we're on the same page, Qt Creator is an IDE, not a database editor so you are trying to build an database interface application, correct ?

                V Offline
                V Offline
                veera
                wrote on 7 Mar 2017, 10:45 last edited by veera 3 Jul 2017, 11:25
                #10

                @SGaist
                Yes I agreed but i am already implemented using QTableview for editing and deleting and adding data from the mssql server existing table same thing i need to grid view for editing and adding deleting data from MSSql server with QT interface.....

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 7 Mar 2017, 20:25 last edited by
                  #11

                  Well that's where it's not clear, AFAIK QTableView + QSqlTableModel gives you the same thing as the GridView from C#.

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

                  V 1 Reply Last reply 8 Mar 2017, 03:52
                  0
                  • S SGaist
                    7 Mar 2017, 20:25

                    Well that's where it's not clear, AFAIK QTableView + QSqlTableModel gives you the same thing as the GridView from C#.

                    V Offline
                    V Offline
                    veera
                    wrote on 8 Mar 2017, 03:52 last edited by
                    #12

                    @SGaist
                    How should i implement data grid view using QTableview + QSqlTableModle on Qt creator?
                    I want to create Qt program with similar layout as C# DataGridView,Can you please provide some example code?

                    M 1 Reply Last reply 8 Mar 2017, 07:13
                    0
                    • V veera
                      8 Mar 2017, 03:52

                      @SGaist
                      How should i implement data grid view using QTableview + QSqlTableModle on Qt creator?
                      I want to create Qt program with similar layout as C# DataGridView,Can you please provide some example code?

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 8 Mar 2017, 07:13 last edited by
                      #13

                      Hi
                      Maybe you can show us a picture of a C# DataGridView ?
                      Like the one you want.

                      V 1 Reply Last reply 8 Mar 2017, 11:09
                      1
                      • V Offline
                        V Offline
                        veera
                        wrote on 8 Mar 2017, 08:19 last edited by
                        #14

                        https://www.google.co.in/search?q=data+grid+view+in+c%23&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjL8JuevMbSAhUDLY8KHSuDDSgQ_AUIBygC&biw=1600&bih=747#imgrc=MYmPHqMg88TvcM:

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 8 Mar 2017, 08:39 last edited by
                          #15

                          Then it's basically a QTableView with the alternatingRowColors property set to true and a couple of QLineEdits and QPushButtons. All in a mix of QHBoxLayout and QVBoxLayout.

                          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
                          • M mrjj
                            8 Mar 2017, 07:13

                            Hi
                            Maybe you can show us a picture of a C# DataGridView ?
                            Like the one you want.

                            V Offline
                            V Offline
                            veera
                            wrote on 8 Mar 2017, 11:09 last edited by
                            #16

                            https://www.google.co.in/search?q=add+edit+delete+gridview,png&tbm=isch&imgil=B9sB6NLZD1_atM%253A%253BlilWqrUInGro4M%253Bhttp%25253A%25252F%25252Fasp.net-informations.com%25252Fgridview%25252Fgridview-operations.htm&source=iu&pf=m&fir=B9sB6NLZD1_atM%253A%252ClilWqrUInGro4M%252C_&usg=__jScs5ApNozfz1cVoi9aqyQJ64Ys%3D&biw=1467&bih=586&ved=0ahUKEwiYnLW84sbSAhVMuI8KHVDvAYIQyjcIJA&ei=R-a_WNjcMczwvgTQ3oeQCA#imgrc=B9sB6NLZD1_atM:

                            M 1 Reply Last reply 8 Mar 2017, 11:23
                            0
                            • V veera
                              8 Mar 2017, 11:09

                              https://www.google.co.in/search?q=add+edit+delete+gridview,png&tbm=isch&imgil=B9sB6NLZD1_atM%253A%253BlilWqrUInGro4M%253Bhttp%25253A%25252F%25252Fasp.net-informations.com%25252Fgridview%25252Fgridview-operations.htm&source=iu&pf=m&fir=B9sB6NLZD1_atM%253A%252ClilWqrUInGro4M%252C_&usg=__jScs5ApNozfz1cVoi9aqyQJ64Ys%3D&biw=1467&bih=586&ved=0ahUKEwiYnLW84sbSAhVMuI8KHVDvAYIQyjcIJA&ei=R-a_WNjcMczwvgTQ3oeQCA#imgrc=B9sB6NLZD1_atM:

                              M Offline
                              M Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on 8 Mar 2017, 11:23 last edited by
                              #17

                              @veera

                              Hi,
                              if you are asking how to insert buttons in the table then you are looking for a delegate

                              http://doc.qt.io/qt-5/qtwidgets-itemviews-stardelegate-example.html
                              http://www.informit.com/articles/article.aspx?p=1405547&seqNum=4
                              http://stackoverflow.com/questions/11777637/adding-button-to-qtableview

                              If its not important that Add/Edit is on each row then some buttons to the side for add/delete is the fastest way.

                              1 Reply Last reply
                              1
                              • V Offline
                                V Offline
                                veera
                                wrote on 8 Mar 2017, 13:14 last edited by
                                #18

                                I want some examples how to do it using qt gui application...

                                M 1 Reply Last reply 8 Mar 2017, 13:40
                                0
                                • V veera
                                  8 Mar 2017, 13:14

                                  I want some examples how to do it using qt gui application...

                                  M Offline
                                  M Offline
                                  mrjj
                                  Lifetime Qt Champion
                                  wrote on 8 Mar 2017, 13:40 last edited by mrjj 3 Aug 2017, 13:40
                                  #19

                                  @veera
                                  That is how.
                                  Use delegate if you want the buttons being part of each row.
                                  The delegate is how u do it.

                                  It is not possible to do in Designer.

                                  1 Reply Last reply
                                  1
                                  • V Offline
                                    V Offline
                                    veera
                                    wrote on 13 Mar 2017, 09:37 last edited by
                                    #20

                                    Hi All,
                                    i am using qt creator for adding ,save and delete the data from table ,here i am using QtTableview and i am not able to delete the particular row using push button method on qt and mssql server.......

                                    1 Reply Last reply
                                    0
                                    • S Offline
                                      S Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on 13 Mar 2017, 10:19 last edited by
                                      #21

                                      What code are you using currently to modify the content of the database ?

                                      Like stated before Qt Creator is just an IDE, you'll have to write a minimal amount of code to interact with your database.

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

                                      V 1 Reply Last reply 13 Mar 2017, 10:52
                                      1
                                      • S SGaist
                                        13 Mar 2017, 10:19

                                        What code are you using currently to modify the content of the database ?

                                        Like stated before Qt Creator is just an IDE, you'll have to write a minimal amount of code to interact with your database.

                                        V Offline
                                        V Offline
                                        veera
                                        wrote on 13 Mar 2017, 10:52 last edited by
                                        #22

                                        @SGaist
                                        for inserting the data
                                        query->prepare("INSERT INTO Entry2 (name,contact,lastname,id,emailid)" "VALUES(?,?,?,?,?)");
                                        showing the data after editing
                                        model->setQuery("SELECT *FROM Entry2");
                                        ui->tableView->setModel(model);
                                        for the same thing for deleting a particular row from the table?

                                        M 1 Reply Last reply 13 Mar 2017, 11:03
                                        0
                                        • V veera
                                          13 Mar 2017, 10:52

                                          @SGaist
                                          for inserting the data
                                          query->prepare("INSERT INTO Entry2 (name,contact,lastname,id,emailid)" "VALUES(?,?,?,?,?)");
                                          showing the data after editing
                                          model->setQuery("SELECT *FROM Entry2");
                                          ui->tableView->setModel(model);
                                          for the same thing for deleting a particular row from the table?

                                          M Offline
                                          M Offline
                                          mrjj
                                          Lifetime Qt Champion
                                          wrote on 13 Mar 2017, 11:03 last edited by
                                          #23

                                          @veera

                                          Hi
                                          Normally you will just use

                                          http://doc.qt.io/qt-5/qsqlquery.html#details

                                          and SQL.

                                          https://www.w3schools.com/sql/sql_delete.asp

                                          1 Reply Last reply
                                          0

                                          13/29

                                          8 Mar 2017, 07:13

                                          • Login

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