Questions tagged [qsqltablemodel]

A QSqlTableModel instance is used in the Qt framework to provide an editable data model for a single database table.

QSqlTableModel is a high-level interface for reading and writing database records from a single table. It is built on top of the lower-level QSqlQuery and can be used to provide data to view classes such as QTableView.

QSqlTableModel can also be used to access a database programmatically, without binding it to a view.

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

206 questions
0
votes
1 answer

Update QSQLTableModel in Qt C++

I created one dialog that is used only to bindValues in a SQL database, and I can save every new record sucessfully. The problem is that I've got another dialog with QSQlTableModel that only shows the information from the database. Every time I make…
Rado G
  • 87
  • 1
  • 5
  • 14
0
votes
1 answer

How to retrieve generated primary key when row was inserted with QSqlTableModel::insertRecord

This question pertains to Qt 4.7.3 on Windows with Postgres. I'm trying to insert a row into a pretty large table via QSqlTableModel, because this (hopefully) saves me the trouble of typing out the field names, by using QSqlTableModel::setTable. I…
average joe
  • 319
  • 4
  • 14
0
votes
1 answer

QT5 and QSqlResult.h

I am trying to port my code from Qt 4.8 to Qt5. I find that enum VirtualHookOperation is not populated in line 128 QSqlResult.h. In Qt5 the enum is empty. I dont find this change mentioned anywhere in the changes-5.0.0 document. I am trying to build…
sky
  • 115
  • 2
  • 10
0
votes
1 answer

Data Entry for a QTableView with QSqlTableModel

I have a basic QTableView displaying data from an SQLite table with QSqlTableModel. Data entry is done by the parent dialog having a number of widgets representing the field data and an "Add" button. Data removal is done via a "Remove selected rows"…
Tim Jones
  • 307
  • 3
  • 11
0
votes
1 answer

Default DB values during inserting new record to QSqlTableModel

How to insert new record to QSqlTableModel with respect to default values of DB? UPD: I am trying to call pTableModel->insertRecord(0, pTableModel->record(0)); or pTableModel->insertRecord(0, pTableModel->record()); or…
Funt
  • 399
  • 8
  • 23
0
votes
1 answer

QTableView does not refresh foreign keys?

I have a QMainWindow with two QTableViewson it. Each QTableView has its own QSqlRelationalTableModel. I am using OnManualSubmit as the edit strategy for both models. Both models hit the same database, and are populated using setTable (each hits a…
David Burson
  • 2,947
  • 7
  • 32
  • 55
-1
votes
1 answer

How to add new rows in a database?

I am creating a simple app for modifying SQLite databases. I am trying to add new rows in MainWindow::on_AddButton_clicked() method, but when I use the MainWindow::on_reselectTable_clicked() method where I reselect SqlTableView, all new rows are…
-1
votes
4 answers

QSqlRelationalTable How to display value from other table in a column with foreign key?

I have a SQLite database with three tables: graph(ID int primary key, name varchar(64)); vertex(ID int primary key, graphID int references graph(ID), name varchar(64), x int default 0, y int default 0); edge(ID int primary key, graphID int…
-1
votes
1 answer

SQL Oracle Command "missing right parenthesis"

every time I want to create this table, it says Missing Right Parenthesis. Can someone please check what i have wrong please. Thank you CREATE TABLE Pet ( PetID Int NOT NULL PRIMARY KEY, OwnerID Char (7) NOT NULL, TypeID Char integer NOT…
Hellz Yeahh
  • 63
  • 1
  • 5
-1
votes
1 answer

build master/detail form using pyqt and qtsql

Edit: Repost with new code and clear question: in the code below you can add and save properly and the question is: I need to do the same but without submitting data to database on row change, I need to be able to add new contact record (master)…
Mohamed Yousof
  • 725
  • 1
  • 9
  • 38
-1
votes
3 answers

SQL. When I trying to do something like "INSERT INTO Table VALUES(x1,x2,x3) - can the x1 x2 x3 be sql queries, like SELECT <...>

I want to do something like this: QSqlQuery q; q.prepare("insert into Norm values(select from Disc id_disc WHERE name_disc=?, select from Spec code_spec WHERE name_spec=?,?"); q.addBindValue(MainModel->data(MainModel->index(MainModel->rowCount()-1,…
Maksim Nesterenko
  • 5,661
  • 11
  • 57
  • 91
1 2 3
13
14