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

Subclassing QSqlTableModel insert new value

I want to show SQL data from a local db-File in a QML-Tableview and than would like to do some edits to the sql-database. What I managed to do after about three weeks: Showing my data in a QML-Tableview. I am not sure if I really need to subclass…
F-Kae
  • 155
  • 1
  • 2
  • 14
1
vote
0 answers

PyQT QSqlRelationalDelegate Combobox

I have a form which has a Qtableview with a QSqlRelationalTableModel. I would like two of the columns to be read only, one to be a combobox and one to be a spinbox but with a specific range (no negative numbers.) Out of the box without a…
Dkellygb
  • 866
  • 2
  • 8
  • 24
1
vote
2 answers

Access qtableview qsqltablemodel from slot

I have seen a lot of tutorials / explanations that discuss similar problems, but I cannot figure out, how to apply it to this situation. I am a Qt/C++ novice and trying to build simple GUI application that connects to an SQLite database. I have UI…
romromrom
  • 33
  • 4
1
vote
1 answer

QSqlTableModel with QTableView - consider DB defined constraint on edit

I have implemented an Oracle database. I use Qt for the GUI of my application and as an interface for the db. Setting up the connection to my db and displaying tables in a QTableView works fine. Edit of all cells is generally natively supported…
Basti Vagabond
  • 1,458
  • 1
  • 18
  • 26
1
vote
2 answers

setData is very slow

I'm trying to optimize a method from a program I developed. Basically, it's a GUI (I use the PyQt library) displaying informations. Informations are stored in a sqlite database. I use a QSqlTableModel and a QTableview to display these informations.…
JPFrancoia
  • 4,866
  • 10
  • 43
  • 73
1
vote
0 answers

Get CSV from QSQLTableModel with correct Locale

I'm trying to convert the QTableView filled with QSQLTableModel data into CSV file. My current code is the following (actually similar to what was posted here already): QFile f( "table.csv" ); if (f.open(QFile::WriteOnly | QFile::Truncate)) { …
1
vote
0 answers

QSqlTableModel inserting new record, getting data is QVariant(invalid)

I have a simple QSqlTableModel: class UsersModel : public QSqlTableModel { Q_OBJECT public: UsersModel(); ~UsersModel(); bool newUser(const QString &name, const QString &surname, const QString…
Pavel K.
  • 11
  • 3
1
vote
0 answers

Python output from Popen command from inside a thread into a GUI form in real time

Being new to Python I have looked around the site and found partial answers but nothing that helps make things clear. This is what I have. The main window through a button activates the thread which runs a command (wash -C -i monX) and a table needs…
1
vote
1 answer

Fastest way to get data from QSqlTableModel and put in QVector

I need to copy two columns from an QSqlTableModel and put into a QVector. I'm trying this: ParameterData pd; QSqlTableModel *m = mapTbModels.value(table); QList parameterList = getFields(table); for (int j = 0; j
nsejxT nsejxT
  • 87
  • 1
  • 4
1
vote
2 answers

Having A Working QSqlRelationalDelegate With QSortFilterProxyModel

I am using QSortFilterProxyModels all the time. However, if a QSqlRelation is setup on the source model, along with a QSqlRelationalDelegate on the view, whenever the view is switched to the proxy model, the QSqlRelationalDelegate disappears,…
1
vote
2 answers

QSqlRelationalTableModel with QSqlRelationalDelegate not working behind QAbstractProxyModel

I need to swap the rows and columns of a QSqlRelationalTableModel. After a lot of searching, I wrote a little proxymodel to flip the rows and the columns. It is partly working. The relations in the table are resolved and showed but the dropboxes to…
logsoft
  • 61
  • 8
1
vote
1 answer

qt multiple QSqlTableModels edited together in one transaction

I have a window in a Qt application using PostgreSQL 9.3 database. The window is a form used do display, edit and insert new data. t looks like that: I have data from 3 sql tables in that view. the tables are related with foreign keys: contractors…
murison
  • 3,640
  • 2
  • 23
  • 36
1
vote
1 answer

Own QSqlTableModel, color whole row based on the value of a QModelIndex

I have extended QSqlTableModel in the past, but currently I'm stuck (still a beginner after all): QVariant MyChild::data(const QModelIndex &index, int role) const { // Check if (soft)deleted / cancelled if(index.column() == 3) { …
user4063815
1
vote
1 answer

How do I edit particular coulmn in QSqlTableModel

I want to display a table from Database and display it, But Also want to modify a particular column based on a function QSqlTableModel *model = new QSqlTableModel(parentObject, database); model->setTable("employee"); …
Tachyons
  • 2,131
  • 1
  • 21
  • 35
1
vote
2 answers

Reimplimenting QSqlRelationalTableModel - data Function Returning String Not Code

Am subclassing QSqlRelationalTableModel. class Titles(QSqlRelationalTableModel): def __init__(self): QSqlRelationalTableModel.__init__(self) self.setTable("titles") self.setRelation(self.fieldIndex("type"),…
user2422819
  • 177
  • 13