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

How to retrieve the value of a QSqlField using Pyside?

It should be so simple. record = self.acctModel.record(self.ui.cbSelectAccount.currentIndex()) field=QSqlField() field = record.field("AccountName") print(field.value) When I print the field value, I get the text
0
votes
0 answers

How to edit string as items from QListWidget using with QDataWidgetMapper

I am using QListWidget, QSqlTableModel, QtableView and QDataWidgetMapper. QListWidget is ItemIsUserCheckable. I am able to save selected items from QListWidget into QtSql table in a single field as string format(converting list items into string as…
user3030327
  • 411
  • 1
  • 7
  • 19
0
votes
0 answers

Pyqt5: QSqlDatabase("QPSQL") not working on port different than 5432

I'm trying use the QSqlDatabase in my code. The connection work well when I use the port 5432 to connect on my PG database. But I can't see any result when try use another port, my tableview is empty, but the connection work. below my code: from…
enzo cocca
  • 35
  • 1
  • 7
0
votes
1 answer

How to convert string to date format in QDataWidgetMapper?

Below is the example code: import sys from PyQt5 import QtCore, QtWidgets, QtSql, uic class FilterProxyModel(QtCore.QSortFilterProxyModel): def __init__(self, parent=None): super().__init__(parent) self._filter_value = None …
user3030327
  • 411
  • 1
  • 7
  • 19
0
votes
1 answer

How to use custome FilterProxyModel and QtCore.Qt.EditRole at a time?

Below is the example code: class FilterProxyModel(QtCore.QSortFilterProxyModel): def __init__(self, parent=None): super().__init__(parent) self._filter_value = None @property def filter_value(self): return…
0
votes
1 answer

How to use for loop to insert row into QSqltablemodel from a list?

Below is the Database model: db = QSqlDatabase.addDatabase('QSQLITE') db.setDatabaseName('book.db') db.open() self.model = QtSql.QSqlTableModel(self) self.model.setTable("card") self.model.select() For example: a = "name" b = 30 c = "M" data_row =…
user3030327
  • 411
  • 1
  • 7
  • 19
0
votes
1 answer

How to search data QSqlTableModel, Qtableview from QlineEdit with the help of QcomboBox?

I am using QSqlTableModel, (FilterProxyModel) as custom proxy modelwith QtCore.QSortFilterProxyModel, QTableView,Qcombobox. self.lineEdit = QtWidgets.QLineEdit(self.centralwidget) self.view =…
0
votes
1 answer

QML Remove Animation of ListView Item with a QSqlTableModel

I'm using a list view with a QSqlTableModel in the background. I use also a SwipeDelegate for the list view elements to provide a "delete button", as shown here: When the button is now pressed, the the item is deleted from the database using this…
Matthias
  • 135
  • 10
0
votes
1 answer

PYQT5 how to change the scheme in mysql odbc connection for QSqlTableModel?

I have a valid ODBC connection to Mysql server with root access Platform Windows 7 64bit, Python 3.6, PyQt5 The connection is to default schema 'accounts'. I want to fetch data from different schema 'acc001' I tried this but no result returned from…
user2035041
  • 69
  • 3
  • 13
0
votes
1 answer

I am using QSqlDatabase and QTableView to display a table but somehow the the GUI shows an empty table(no header even)

class Window2(QMainWindow): def __init__(self): super().__init__() win = QWidget() self.title = "Court Case Database Management System1" self.top = 200 self.left = 500 self.width = 400 self.height…
Imdumb
  • 9
  • 2
0
votes
0 answers

QT SQLite Can't get table info

I'm using C++ with QT 5.7.0 for processing some legacy DB (SQLite3). The DB has many tables with names 00.00.00/00:00_data_N. I can properly get data from this tables with sql query like this: SELECT * from '00.00.00/00:00_data_N' ORDER BY id And I…
murzagurskiy
  • 1,273
  • 1
  • 20
  • 44
0
votes
0 answers

How can I inform views in separate windows when using MVC in a Qt/c++ project?

I use MVC pattern, sqlite database in my code. I want to show my same data in different views, in the separate windows at the same time. Also, I want to update my data. I implement the model in a class and I call the model function as needed. …
roboTURX
  • 1
  • 1
0
votes
1 answer

Query makes table with QTableView and QSqlTableModel uneditable

I need to perform a query to limit the rows displayed in a table. I chose QTableView/QSqlTableModel for the read-write functionality. Unfortunately, my query makes the table uneditable. Edit: This is not my real program. I will be using a few tables…
0
votes
1 answer

How to store Date values as integers into SQLite using QSqlTableModel

I am trying to store Date values from Qt application into SQLite database as integers. I have created date delegate with these functions implemented: QWidget* DateDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, …
lucky62
  • 169
  • 7
0
votes
1 answer

Commit QSqlRelationalTableModel model changes to database

I've modified the relational table model at https://doc.qt.io/qt-5/qtsql-relationaltablemodel-relationaltablemodel-cpp.html I want to be able to save my changes to my database, but it only saves the first two columns, not the primary key lookup…
user1801060
  • 2,733
  • 6
  • 25
  • 44