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

How to submit data to the QSqlTableModel that has been changed by the user on the QTableView

I'm trying to retrieve the input from the user when modifying the QTableView as seen in the photo and then updating the QSqlTableModel in order to get my database modified. The problem is that QTableView has no signals as QTableWidget for example,…
0
votes
0 answers

QSqlTableModel list of transactions

I am writing a PyQt6 QSqlTableModel application. I'm using manual update and submitAll(). I want to capture the sql statements which were successfully executed. The executedQuery() method reports only the last query, but several may have been…
fossildoc
  • 31
  • 5
0
votes
0 answers

QSqlTableModel: setData does not work in subclass

QSqlTableModel updates the data when directly used but while subclassing setData does return true but updates nothing: enum ItemRoles { CONTENTROLE = Qt::UserRole + 1, TYPEROLE = Qt::UserRole + 2, VIEWSROLE = Qt::UserRole + 3, …
dev-Bilal
  • 1
  • 1
0
votes
0 answers

PyQt6 - replacing the values ​ in the QTableView column, QSqlTableModel model

There is not enough experience and knowledge to solve the problem of replacing the values ​​"1" and "0" with "Working" and "Not working" in the column "Status" of my model. It seems I should be using a delegate or should I override the…
snkip
  • 1
  • 2
0
votes
0 answers

How to manage multiple SQLite databases in a Qt C++ program?

I am writing a program in Qt creator. I have a treeview and a tableview. Each time an item in the treeview is clicked, I need to update the tableview. The problem is that the tables realted to each tree item is different. Since the tableview works…
0
votes
0 answers

Python QSqlRelation

I am using a QtableView to display data from a QSqlRelationalTableModel which seems to work fine, however when I use self.motormodel.setRelation(1, QSqlRelation('Instruments', "Asset Tag","Description" ))…
0
votes
1 answer

How to know if data updated successfully in database when using QSqlTableModel.OnFieldChange editStrategy in QSqlTableModel?

I am using QSqlTableModel and QTableView to represent my database. I have successfully inserted rows to tableModel: self.tableView = QtWidgets.QTableView(self.verticalLayoutWidget) self.table_model = QSqlTableModel(self.tableView, database) …
0
votes
0 answers

Issues with mapping QSqlTableModel to QTreeView using QAbstractProxyModel

I am trying to implement a QAbstractProxyModel that maps an SqlTableModel to a tree-like data structure. The table has a column called parent_id, whose value is added to the createIndex call as a third argument. The question is similar to this…
0
votes
1 answer

How to iterate over QSqlTableModel and export to .csv

I'm trying to export data from SQlite3 database to .csv, using pyqt5, QSqlTableModel and csv. I can export all the data from my database, I'm trying to export only the selected rows from QSqlTableModel, I really liked to mess around QSqlTableModel…
0
votes
0 answers

I am switching in between a QMainwindow and Qdialog window but when I exit my QDIALOG It causes the whole program to crash

from PyQt5.QtWidgets import QWidget from PyQt5.QtWidgets import QDialog from PyQt5 import uic from PyQt5.QtWidgets import QApplication from PyQt5.QtWidgets import QPushButton from PyQt5.QtWidgets import QLineEdit from PyQt5.QtWidgets import…
Gabriel
  • 53
  • 5
0
votes
0 answers

PyQT QSqlTableModel insertRecord problem in tables with an auto increment primary key

I have looked around for the solution to my problem a lot and haven't found anything. The problem is with inserting a new record into a database table that has an auto increment primary key. Below is the different scenarios and behaviors that I'm…
nanda
  • 71
  • 6
0
votes
1 answer

How to retrieve more than one row with the checked checkbox in QTableView

I am developing an app, where user can select multiple (<=5) rows to preview. I have used QSqlTableModel with QTableView. In order to retrieve data I am using following line of code: out =…
Sudipto21
  • 37
  • 1
  • 6
0
votes
1 answer

I am using QSqlTableModel in Qt, but select function is returning a false

I am having problems using the select function for QSqlTableModel. It always returns false and I have been unable to figure out why. I have setup a SQL Database using PostgreSQL. I was able to add the database using QSqlDatabase::addDatabase and I…
Nekreg45
  • 1
  • 2
0
votes
1 answer

QSqlTableModel with WHERE condition

How can i show a table with QTableView and WHERE condition ? ...WHERE numero_conta = 123; self.model = QSqlTableModel() self.model.setTable('historico') self.model.select() self.tab_extrato =…
Eduardo Silva
  • 25
  • 1
  • 6
0
votes
1 answer

is it possible to reorder QSqlTableModel from QListView?

I'm trying to reorder this QSqlTableModel from a QListView but it seems impossible i tried every thing i found on the internet ( offical documentation, examples forums blogs ) but Nothing happend,i activated the moving action and override flags…
miyou995
  • 77
  • 10