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
2
votes
1 answer

QSqlRelationalTableModel only populates first 256 records

I have the following simple model using PyQt5, sqlite3 and python3.5.2. class choicesModel(QDialog): def __init__(self, parent=None): super(choicesModel, self).__init__() query = QSqlQuery() query.prepare("SELECT…
GM65
  • 23
  • 4
2
votes
1 answer

PYQT: QSqlTableModel. How to filter numbers instead of Text

I'm developing a GUI which allows nurses and doctors to view or patients records from a sqlite database. I have been able to design a way to filter the rows using the setFilter fuction. However, here is my dilemma: The discrete fields which search …
Jeremy Scott
  • 167
  • 1
  • 3
  • 15
2
votes
0 answers

Updating row via setRecord in QSqlTableModel

I use Qt 5.7, C++, SQLite database. I have QSqlTableModel descendant class. I update rows via setRecord(), submitAll() calls (QSqlTableModel::OnManualSubmit mode). Let's set value_1 to field_1 in a single row. It is saved correctly in database, also…
ilya
  • 1,103
  • 14
  • 36
2
votes
1 answer

How to show the filtered data of QSqlTableModel in another tableView in Qt?

I have loaded a database by using QSqlTableModel, and show it in tableView1. Now, I have setup a filter for this QSqlTableModel, and want to show the filtered data in tableView2. tableView1 and tableView2 should not interact with each other. Then,…
stackname
  • 101
  • 2
  • 9
2
votes
1 answer

PyQt - trouble with reimplementing data method of QSqlTableModel

I'm a newbie with python and mainly with pyqt. The problem is simple: I have a QTableView and I want to "simply" change the color of some rows. Reading all around I found that the simplest solution should be to override the data method in the model…
paky79
  • 21
  • 3
2
votes
1 answer

PyQt5 QSqlTableModel not updating changes to database

I have a PyQt5 Application connecting to a MySQL database. I made two views connected to the same model. The views pull in data from the database just fine. Any change I make to any field in one is reflected in the other. But it does not update the…
askast
  • 73
  • 1
  • 6
2
votes
0 answers

Qt 5.3.1 introduced issue with QSqlTableModel and QSortFilterProxyModel

I am using QSortFilterProxyModel for a lot of data models and it worked fine. After updating from Qt5.3.0 to Qt5.3.1 this changed partly. One of my GUI panels uses a QTreeView attached to a QSortFilterProxyModel attached to a QSqlTableModel. The SQL…
Silicomancer
  • 8,604
  • 10
  • 63
  • 130
2
votes
1 answer

QDataWidgetMapper and QDateEdit values

I have QSqlTableModel with some table, let's suppose that it's a model->setTable("Person"); And also I have QDataWidgetMapper which mapps some widgets (lineedits etc.) to appropriate columns in model. So the problem is in QDateEdit element.…
Daniel
  • 635
  • 1
  • 5
  • 22
2
votes
1 answer

Resolving complex foreign keys in QSqlRelationalTable

I'm working with QSqlRelationalModel and I have some problem. For example if we deal with simple tables like: Location +------+--------+ | id | name | +------+--------+ Department +------+-------------+ | id | location_id…
Daniel
  • 635
  • 1
  • 5
  • 22
2
votes
2 answers

How to get the value in QSqlTableModel?

My database: My code: QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("sqlite.db"); db.open(); QSqlQuery query; query.exec("SELECT * from Expenses"); QSqlTableModel *model = new QSqlTableModel(0,…
Adam Shakhabov
  • 1,194
  • 2
  • 14
  • 35
2
votes
1 answer

QDataWidgetMapper only updates first index to QSqlRelationalTableModel

I have a problem regarding parts of the QT framework. I am using QT 5.0.2 and am developing on Windows at the moment. In my application I have a Tableview set up with a QSqlRelationalTableModel. Next to it I have a text field and 3 combo boxes…
sascha
  • 23
  • 4
1
vote
1 answer

How to replace rows with columns in QSqlTableModel?

I found a lot of answers how to transform rows into columns in SQL. But I need to transforms rows into columns in QSqlTableModel. As I understand it should not be a very difficult task but I can't find any idea of how to realize it. Perhaps data(),…
Funt
  • 399
  • 8
  • 23
1
vote
1 answer

Sort by Multiple Columns in PyQt Model

I want to use the PyQt equivalent of the following SQL statement in my model/view-based PyQt application: SELECT * FROM table ORDER BY foo, bar How do I sort by multiple columns in a QSqlTableModel, especially since setSort() accepts a single…
user191776
1
vote
1 answer

Running parameterized queries in QSqlTableModel

I have a QTableView and I am using a derived class SqlTableModel of QSqlTableModel to fetch data from a MySQL database. I want to prevent injection. I ran a union injection and it was easier than taking candy from a baby. The SQL query utilizes the…
user14773854
  • 303
  • 4
  • 10
1
vote
0 answers

Updating a relational column in QSqlRelationalTableModel (PyQt6)

So, I’m stumped by a problem when updating a record on a relational column in a QSqlRelationalTableModel with PyQt6. Background: I’m developing an app which includes a GUI to keep track of clients. The clients (companies) are stored in a…
1 2
3
13 14