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

Issues with row creation/deletion when editing QSqlTableModel via QTableView

I'm using PySide6 with Python 3.10 to create an app that is using an SQLite DB to record some data points. I'm having difficulties with the QtSql module, in particular regarding the QTableView-QSqlTableModel interaction and the ability to…
Kastakin
  • 121
  • 1
  • 9
1
vote
1 answer

Update foreign key in Qt QSqlRelationalTableModel

I'm coding in python (PySide2), but the overall concept concerns the Qt Framework. Here are two tables of mine: Table "recordings": | Column | Type | | -------- | -------------------| | id | int (primary key) | | param1 …
Buzz
  • 1,102
  • 1
  • 9
  • 24
1
vote
1 answer

How to deal: qsqltablemodel does not load view

I have a pretty simple system of 2 views in SQLite DB and 2 tableViews in Desktop Qt Widget Application: First view is 'seller_view' and it is just printed in App's tableView correctly via QSqlTableModel. Second is 'customer_view' (setup is the…
SageCat
  • 315
  • 1
  • 13
1
vote
1 answer

Pyside6 inserting a row into a QSqlRelationalTableModel

I am trying to insert a row into a PostgreSQL database using a QSqlRelationalTableModel. The connection works and I can edit the data in the tableview. However, I am stuck with trying to insert a new row. The error is because of NULL values for the…
Mark
  • 11
  • 2
1
vote
0 answers

PyQt5 Qsqltablemodel datatypes "incompatible in the equal to operator" with data over 128 characters

I'm currently working on a PyQt5 based software that connects to a SQL database for managing assignments for a large number of people. The URLs for these assignment documents are quite long, going up to ~260 characters, and I have been encountering…
1
vote
0 answers

Remove Row in subclassed QSQLTableModel not updating database

I have subclassed QSQLTableModel to control different display stuff in Table View (such as red color for negative values, dynamic number of decimal digits, etc..) and that works fine. When I've tried to remove a row the method is not working, not…
NunoA
  • 11
  • 2
1
vote
1 answer

Resizing a QTableView column horizontally to the content of an item delegated column which is painted with a new text in Qt

I want to show my database tabel content in a QTableView. I use the following codes to do that: QSqlDatabase test =…
1
vote
1 answer

I cannot get my QSQLTableModel to connect to my database, so it does not populate the model when i call the select() method on the model,

The class below is a QMainWindow that is meant to use a QTableView as a central widget to show my contacts table in my database but I have been unable to get my QSQLTableModel object to connect to the database for some reason, the database file is…
Gabriel
  • 53
  • 5
1
vote
1 answer

How to copy selected row data from QSqlTableModel tableview into reqired Qlineedit input widgets?

Example images: Below is my example code: from PyQt5 import QtCore, QtGui, QtWidgets, QtSql from PyQt5.QtWidgets import * from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtSql import * from PyQt5 import uic import sys import…
user3030327
  • 411
  • 1
  • 7
  • 19
1
vote
0 answers

Issue with proxymodel and buttons

Just to let you all know I am new to C++ Qt5. I am working on a QsqlTableModel QTableView project using an existing SQLITE db. I have two issues I am trying to resolve without any success. the buttons all work as expected until I add the proxymodel…
1
vote
1 answer

Table is still exist after dropping it and the whole database too

I get this message after I dropped the table and the database completely Msg 2714, Level 16, State 6, Line 12 There is already an object named 'Users' in the database I tried to create and drop the same database but no use. I also dropped the…
Elassoa
  • 133
  • 2
  • 18
1
vote
1 answer

QSqlTableModel data edit (subclassing) problem

I'm in trouble with a small application I'm trying to write in Python 3.7 and PyQt5. I'm quite new to Python and my knowledge on C++ is near to 0 (zero). At the end, my project will have a Tableview whose model is a QsqlTableModel linked to a…
bigfefi
  • 23
  • 3
1
vote
1 answer

QSqlTableModel: Where can I get whether a row is marked as removed

If I call removeRows on records which were read from the database a ! will be displayed in the first column of the tableView. The only thing which I would like to achieve is that this row will not be displayed in the view. I tried it with…
Bumblebee
  • 513
  • 2
  • 4
  • 15
1
vote
1 answer

Dealing with changed rows during storing on a QTreeView with QSqlTableModel

I have a QTreeView which displays a result from SQLite via QSqlTableModel (PyQt5 version: 5.13.0). I want to change some values via a detail-dialog which populates the data via modelTable.record(). Therefore I set the edit strategy to OnManualSubmit…
ProfP30
  • 358
  • 3
  • 18
1
vote
1 answer

Adding a column from a diffent table to a pivot table on SQL

I am new to sql and try to figure out a "lookup" column to a pivot table. I have managed to make a pivot with first column as the Primary key. Then I want to add a column from a different query, that is from joined tables. I have both the pivot…
burak
  • 33
  • 1
  • 4