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

pyqt5 fails to inserts bytes

How do you insert a bytes object into a database. Whenever I attempt this I end up with an empty string (not NULL) being inserted. with open(filepath, 'rb') as f: filehash = hashlib.md5(f.read()).hexdigest() img_pkl = pickle.dumps(img,…
Zak
  • 936
  • 10
  • 19
0
votes
2 answers

PyQt: QTableView + QSqlTableModel - Copy and Paste All Selected Rows or Columns into Notepad or Excel

To start, I've already looked at ekhumoro's code on a nearly similar subject Here. However, when I attempt to implement this code, I am getting a different result. Instead of copying and pasting all the I selected, it only copies the first cell of…
Jeremy Scott
  • 167
  • 1
  • 3
  • 15
0
votes
1 answer

"Incorrect string value" for polish characters (QSqlTableModel, MySQL)

I'm having problem when adding record to QSqlTableModel: QString name = out.getName().left(384/6); //UTF-16 max bytes/char = 6 qDebug() << "name:" << name; record.setValue("name", name); //VARCHAR(384) record.setValue("data", out.getData()); if…
smsware
  • 429
  • 1
  • 13
  • 41
0
votes
1 answer

QSqlTableModel: last checkstate change doesn't reflect on database

I have MySQL database, QSqlTableModel and QTableView with few checkbox columns. It works, but the last click on checkbox does not cause changes in database. It means that if I launch a program, click on some checkbox once and close program, no…
user4489658
0
votes
0 answers

View doesn't display data from the model

int main(int argc, char *argv[]) { QApplication a(argc, argv); After making connection, I tried this code , but it doesn't display any data QSqlTableModel *model=new QSqlTableModel; model->setTable("tamp"); model->select(); …
Katrin
  • 5
  • 2
0
votes
1 answer

QSqlTableModel filter no results

I'm trying to access mysql a database in qt c++. I have different tables and want to output them on a QTableView. I use the QSqlTableModel, which works great, but as soon as I want to filter the results I run into problems.. Here is the main part of…
linux_lover
  • 125
  • 1
  • 13
0
votes
1 answer

Modifying data representation in Qt model/view

I am using Qt 5.4.2 and I have trouble in trying to find out, how to change data "representation" when populating a view from model. I have a QSqlTableModel to hold the database data and a QTableView that is displaying the contents of the…
user55340
  • 87
  • 1
  • 6
0
votes
1 answer

Automatically updating QSqlTableModel and QTableView

I have created a model using QSqlTableModel, then created a tablview using QTableView and set the model on it. I want to update the model and view automatically whenever the database is updated by another program. How can I do that?
0
votes
1 answer

QtQuick setting up model in TableView

so I have a tableview on a qmlfile, I'm trying to set the model from c++. The model I'm using is QSqlTableModel, if a create a new tableview and set the model from c++ it seems to work, but when I pass the model to the model property in the qmlfile…
heczaco
  • 198
  • 1
  • 13
0
votes
0 answers

Qt: How to send a SQLTableModel from server to client

I am working on a client-server project. On the client side, I have a few GUI windows containing different views (QTableView, QListView). I can send messages to the server just fine using the following method: QByteArray bArray; QDataStream…
Quintin96
  • 25
  • 2
  • 6
0
votes
1 answer

QSqlTableModel - filter not working?

I created a QSqlTableModel, set a filter and used a QTableView to show a table of my filtered data. This works as expected... model = new QSqlTableModel; model->setTable("XXX"); model->select(); model->setFilter(filter); table = new…
joe4
  • 1
  • 2
0
votes
0 answers

QSqlTableModel: white spaces in the column names bad?

I'm connecting to an MS SQL table (from Linux) using the Microsoft ODBC driver. Note that if "MyTable" points to a table with no spaces in the columns, everything is fine. For the other table (the one I need to be reading from) things go…
kiss-o-matic
  • 1,111
  • 16
  • 32
0
votes
2 answers

Qt Table model to Tree model

In Qt I have a sqlite database which I'm pulling in. One of the tables (configTable) has a QSqlTableModel attached. The table has a simple 2-column key/value structure. The keys are strings with folder-like values such as "general/name",…
Kver
  • 767
  • 5
  • 19
0
votes
2 answers

Subclassing QSqlTableModel to setup database

I'm trying to subclass QSqlTableModel so that the constructor will set up the database that is needed for the model. My code looks something along the lines of: MyClass::myClass( QObject* parent, QSqlDatabase data ) :QSqlTableModel(parent,…
Paul
  • 370
  • 3
  • 12
0
votes
0 answers

Qt Combobox Model Using SQLite

With Sq-lite, how can I set a model for the combo-box that has two table columns added together (ie surName +' '+ firstName)...with MS SQL Server I simply use a view. When I tried with Sq Lite...nope! all other widgets (ie.QLineEdit and QDateEdits)…
Kyef
  • 69
  • 7