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
1
vote
2 answers

QSqlTableModel and DATETIME columns

I have a QTableView displaying a table using a QSqlTableModel. In that table, I have a DATETIME column. When I add a line and try to edit that column, I have a simple QEdit. I would like to have a QDateTimeEdit (or similar) there, it would be much…
Ulrar
  • 895
  • 8
  • 17
1
vote
1 answer

How to save the updated_date when a data change in the TableView?

I'm trying to use QSqlTableModel with a QTableView, but i want to hide the 2 columns updated_date and created_date, its easy, but i want that the user can edit a data in the TableView, and when finish (or when submit that data) automatically the…
1
vote
1 answer

Qt QSqlDatabase and QSqlTableModel compatibility with PostgreSQL view?

I have encountered a problem using QSqlTableModel on PostgreSQL view. Let me show the relevance code here first. a view is created with the following code running on PostgreSQL 9.2.4: CREATE OR REPLACE VIEW reporters_spaces_edit AS SELECT…
crackpot
  • 333
  • 1
  • 2
  • 16
1
vote
2 answers

How to show only specific rows in QSqlTableModel using combo box text?

I'm using QSqlTableModel in Qt C++ and I would like to show only the rows that contain the text that is in the QComboBox. For example, when I click on the "John" item in the combo box, the table view should show me only the names that start with…
Rado G
  • 87
  • 1
  • 5
  • 14
1
vote
1 answer

How to display content of multiple QSqlTableModels in one QTableView?

I have a MySql table, let's call it x: CREATE TABLE x ( Id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, A int unsigned NOT NULL, B int, FOREIGN KEY (A) REFERENCES y(Id) ); And then I have another table, let's call it y: CREATE…
user2494829
1
vote
1 answer

QSQLTableModel inheritor and QTableView

I wrote QSQLTableModel inheritor for working with qml and it's work well. I need use it with QTableView too, data shows, but I cannot modify it - when I edit everything is ok, but all changes drop when I get out from field (I know about…
aknew
  • 1,101
  • 7
  • 23
1
vote
1 answer

How to submit only one row in QSqlTableModel?

I use QSqlTableModel with OnManualSubmit edit strategy. I have possibility to revert changes for some row with revertRow() method. But how can I submit only one row of table? I have only submitAll() method. I could use insertRowIntoTable(), but it…
Funt
  • 399
  • 8
  • 23
1
vote
1 answer

QListView losing selection on edit

I have a QListView pulling data from a QSQLTableModel. Upon a user clicking an 'Add' button, I add a new item and open it for editing: QSqlTableModel *tblModel= qobject_cast
Tim Jones
  • 307
  • 3
  • 11
1
vote
0 answers

How to select QTableView row based on my Sqlite Query?

My application is a two window application, where in one of them you can change the position and mark points that are added to my SQL DB, and the other where you can view the marked point. I've got a QTableView with aQSqlTableModel. The model is…
1
vote
1 answer

QSqlTableModel/ QTableView parsing queries to xml

This is my first post to this forum and I hope the problem I am asking for solution is explained clearly . I am using QSqlTableModel and QSqlTableView for viewing a table of the DB. The cached table model is what I was looking for, that's why I…
1
vote
0 answers

QDataWidgetMapper not working correctly with QSqlTableModel in PyQt when setOrientation is Vertical

I have a strange problem. The following code works perfectly if I only map two widgets to the first two rows of a SQLITE table ("simpletable"). The widgets are filled at startup and the table is correctly updated when I edit the widgets and click…
LozzerJP
  • 856
  • 1
  • 8
  • 23
1
vote
1 answer

PyQt4 Selected Item Text in QTableView delayed by one click

I'm using a QTableView to display contents of a QSqlTableModel along with using a QSortFilterProxyModel to filter the records. In the following code I've managed to get the selected text to be displayed when a user clicks the cell (regardless if a…
Steve Lee
  • 125
  • 2
  • 8
1
vote
1 answer

How to increase performace on a sqlite3 database that uses QT?

I am using QSQlQuery on a sqlite3 database. To fetch a particular item , I was populating the result from 4 different tables. I thought joining the tables would increase the performance/speed and get the result faster. So I joined 2 tables initially…
user1065969
  • 589
  • 4
  • 10
  • 19
1
vote
1 answer

how get the row state of a row in QSqlTableModel?

I have a QSqlRelationalTableModel. I am using OnManualSubmit for my edit strategy. I have called setTable and insertRow. Later, how do I know programmatically which rows have been added or edited in the model but have not yet been submitted to the…
David Burson
  • 2,947
  • 7
  • 32
  • 55
0
votes
2 answers

Additional empty row in QSqlTableModel

I'm trying to add always-empty last row. Now I have proxy model, on which I'm calling insertRow() - the row is inserted. But I need to add another row, when last row is updated (data is inserted). To which signal should I connect? Weird error occurs…
myky
  • 55
  • 1
  • 5