qsqltablemodel

How to create filter rows for Qtableview with using QSqlTableModel.?

a 夏天 提交于 2020-08-20 07:16:36
问题 Is it possible to create row filter for Qtableview with QSqlTableModel. I am sing " QSqlTableModel" to show the data on Qtableview from SQLite thats working. But i am trying to filter rows. When i am executing the code i am getting below error is line 44, in for row in range(self.model.rowCount()) AttributeError: 'QSqlTableModel' object has no attribute 'item' I Tried but did not get any solution. Is it possible to make this with QSqlTableModel? i want to show filtered items from tableview

How to create filter rows for Qtableview with using QSqlTableModel.?

谁说我不能喝 提交于 2020-08-20 07:15:44
问题 Is it possible to create row filter for Qtableview with QSqlTableModel. I am sing " QSqlTableModel" to show the data on Qtableview from SQLite thats working. But i am trying to filter rows. When i am executing the code i am getting below error is line 44, in for row in range(self.model.rowCount()) AttributeError: 'QSqlTableModel' object has no attribute 'item' I Tried but did not get any solution. Is it possible to make this with QSqlTableModel? i want to show filtered items from tableview

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

亡梦爱人 提交于 2020-01-25 21:28:12
问题 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 the selected row or rows respectively. I need users to be able to select multiple rows or columns and paste those values in either excel or notepad. Any ideas? GUI: Code: from PyQt4 import QtCore, QtGui, QtSql import sys import sqlite3 import time

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

我是研究僧i 提交于 2020-01-25 21:28:00
问题 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 the selected row or rows respectively. I need users to be able to select multiple rows or columns and paste those values in either excel or notepad. Any ideas? GUI: Code: from PyQt4 import QtCore, QtGui, QtSql import sys import sqlite3 import time

Custom QAbstractItemDelegate with regex for QSqlTableModel

淺唱寂寞╮ 提交于 2019-12-25 16:47:35
问题 I'm trying to create a custom delegate so I can use Regex to verify the data that's being entered into the table but for some reason, my code keeps throwing errors, is there a good structured example? These are the two errors I'm currently getting, and when I fix the AttributeError: 'QLineEdit' object has no attribute 'set' by using QLineEdit.setText my regular expression doesn't work and it allows any value to be added in. Traceback (most recent call last): File "F:\Computing\Program V3

How to replace rows with columns in QSqlTableModel?

青春壹個敷衍的年華 提交于 2019-12-25 08:18:59
问题 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(), setData() and some other methods could be reimplemented, but I am afraid to miss something... Or, maybe, some methods of QTableView should be reimplemented. 回答1: As I understand QIdentityProxyModel could be used to solve this problem. Unfortunately

Subclassing QSqlTableModel insert new value

穿精又带淫゛_ 提交于 2019-12-24 08:25:19
问题 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 QSqlTableModel and I definitly would be glad if subclassing would not be neccessary at all. In my main.cpp following should create my model and directly add a record. // Create an instance of the SqlModel for accessing the data SqlDataModel *sqlModel

Implementing setEditStrategy in editable QSqlQueryModel

巧了我就是萌 提交于 2019-12-22 05:08:16
问题 This is a follow-up to this question. In there, we created an editable subclass of QSqlQueryModel, to use with complex queries. Now I need to add a functionality like QTableModel's setEditStrategy so I can cache all changes and accept or revert them using buttons. PyQt apparently doesn't allow multiple inheritance and I cannot find sufficient documentation to re-implement this method in my custom model, therefor here's the question: How can I re-implement QSqlTableModel.setEditStragety (or

When or how to use fetchMore() on QSqlTableModel with a SQLite database for rowCount() to work?

末鹿安然 提交于 2019-12-21 16:47:17
问题 My class DataTable is derived from QAbstractTableModel. It uses a QSqlTableModel object internally to fetch data from a db table. It represents a record for every row in the db (it does more but the record count is always the number of rows in the db table). With MySql, my DataTable::rowCount() implementation just calls rowCount() on the QSqlTableModel, which works nicely. Now with SQLite, Qt's SQLite driver returns a row count of 256 if there are more than 256 rows in the db table, so my

Editable QTableView of complex SQL query

一世执手 提交于 2019-12-20 05:45:26
问题 How can I make an editable QTableView displaying data from a complex SQLite query? I need to fill a QTableView with data from several SQLite tables. This needs to be editable by the user. As the queries are a bit complex (including JOINs and CASE WHEN etc.), I'm doing this via a QSqlTableModel and a QSqlQuery. I have been told, however, that this is not how QSqlTableModels should be used. So, can someone please show me how to get a result like the one shown here via the proper way? Also,