qsqlquerymodel

Adding CheckBox with QSqlQueryModel shown in QTableview and other columns are empty

拟墨画扇 提交于 2019-12-25 01:46:34
问题 I am using the code in this answer to add checkbox in tableview. I want to show it in the first column. Here is my code: mysqlquerymodel.h #ifndef MYSQLQUERYMODEL_H #define MYSQLQUERYMODEL_H #include <QObject> #include <QMap> #include <QModelIndex> #include <QSqlQueryModel> class MySqlQueryModel : public QSqlQueryModel { Q_OBJECT public: explicit MySqlQueryModel(QObject *parent = 0); Qt::ItemFlags flags(const QModelIndex & index) const; QVariant data(const QModelIndex & index, int role) const

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

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,

How to show QSqlQueryModel in QML?

半世苍凉 提交于 2019-12-17 13:52:19
问题 I want to show QSqlQueryModel in qml TableView but I don't Wan't to create separate QML file for each new query cause I can't create infinite qml files as given here . Also question is not working for me for dynamic number of columns (could be version difference as I am using 5.11) .I just want something like:- QTableView *view = new QTableView; view->setModel(model); view->show(); in QML. I am new to qml. So far I am able show QSqlQueryModel as guided in first link but my user may enter any

How to show QSqlQueryModel in QML?

帅比萌擦擦* 提交于 2019-12-17 13:51:32
问题 I want to show QSqlQueryModel in qml TableView but I don't Wan't to create separate QML file for each new query cause I can't create infinite qml files as given here . Also question is not working for me for dynamic number of columns (could be version difference as I am using 5.11) .I just want something like:- QTableView *view = new QTableView; view->setModel(model); view->show(); in QML. I am new to qml. So far I am able show QSqlQueryModel as guided in first link but my user may enter any

Implementing setEditStrategy in editable QSqlQueryModel

社会主义新天地 提交于 2019-12-05 05:16:14
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 something like it) including RevertAll() and SubmitAll() in an editable QSqlQueryModel? Here's a CVME:

Editable QTableView of complex SQL query

江枫思渺然 提交于 2019-12-02 12:31:16
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, while my QTableViews are editable, the results don't seem to get stored in the SQLite database. (When I

How to show QSqlQueryModel in QML?

被刻印的时光 ゝ 提交于 2019-11-28 11:49:01
I want to show QSqlQueryModel in qml TableView but I don't Wan't to create separate QML file for each new query cause I can't create infinite qml files as given here . Also question is not working for me for dynamic number of columns (could be version difference as I am using 5.11) .I just want something like:- QTableView *view = new QTableView; view->setModel(model); view->show(); in QML. I am new to qml. So far I am able show QSqlQueryModel as guided in first link but my user may enter any SQL Query. Using information from A more generic approach of How to Use a QSqlQueryModel in QML you can