Created
July 12, 2020 05:13
-
-
Save chilarai/d9963f183b5050abab5d0b1e24a5acb8 to your computer and use it in GitHub Desktop.
mysqlmodel.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef MYSQLMODEL_H | |
#define MYSQLMODEL_H | |
#include <QObject> | |
#include <QSqlQueryModel> | |
#include <QSqlRecord> | |
#include <QSqlField> | |
class MysqlModel : public QSqlQueryModel | |
{ | |
Q_OBJECT | |
public: | |
explicit MysqlModel(QObject *parent = nullptr); | |
void setQuery(const QString &query, const QSqlDatabase &db = QSqlDatabase()); | |
void setQuery(const QSqlQuery &query); | |
QVariant data(const QModelIndex &index, int role) const; | |
QHash<int, QByteArray> roleNames() const; | |
Q_INVOKABLE void callSql(QString queryString); | |
private : | |
void generateRoleNames(); | |
QHash<int, QByteArray> m_roleNames; | |
signals: | |
}; | |
#endif // MYSQLMODEL_H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment