Creating a table with grid view adding, editing and deleting data from the MS SQL server using Qt Creator
-
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 ......
-
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 ?
-
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 ?
@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..... -
Well that's where it's not clear, AFAIK QTableView + QSqlTableModel gives you the same thing as the GridView from C#.
-
Well that's where it's not clear, AFAIK QTableView + QSqlTableModel gives you the same thing as the GridView from C#.
-
@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?Hi
Maybe you can show us a picture of a C# DataGridView ?
Like the one you want. -
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.
-
-
Hi,
if you are asking how to insert buttons in the table then you are looking for a delegatehttp://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-qtableviewIf its not important that Add/Edit is on each row then some buttons to the side for add/delete is the fastest way.
-
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.
-
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.
@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? -
@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? -
Why not use QSqlTableModel ?
-
yeah i tried using QSqlTableModel ,here below code instead of passing row on model.setFilter ,need to pass from UI using pushbutton method whichever row i can delete using delete push button method in a generic way....
model.setTable("Entry");
model.setFilter("id = 1");
model.select();
if (model.rowCount() == 1) {
model.removeRows(0, 1);
model.submitAll();
} -
Hi All,
I want to develop this type of grid view like after clicking edit button for each row of table please refer this link
"http://www.c-sharpcorner.com/uploadfile/1e050f/edit-and-update-record-in-gridview-in-asp-net/" .....guide me for implementing same grid view using Qt and MS Sql server.....