Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <QtGui/QApplication>
- #include <QtCore/QDir>
- #include <QtCore/QSettings>
- #ifdef STATIC_BUILD
- #include <QtCore/QtPlugin>
- Q_IMPORT_PLUGIN(qjpeg)
- Q_IMPORT_PLUGIN(qsvg)
- #endif
- #include <QSqlDatabase>
- #include <QSqlQuery>
- #include <QSqlRecord>
- #include <QDebug>
- int main(int argc, char *argv[])
- {
- QApplication a(argc, argv);
- QSqlDatabase db;
- // Find QSLite driver
- db = QSqlDatabase::addDatabase("QSQLITE");
- db.setDatabaseName("test.db");
- db.open();
- QString query("SELECT field1, field2 FROM table1 WHERE field3 = '1'");
- QSqlQuery sqlQuery(db);
- sqlQuery.exec(query);
- int columnsNumber = sqlQuery.record().count();
- QList<QStringList*> results;
- while (sqlQuery.next())
- {
- QStringList *record = new QStringList();
- for (int i = 0; i < columnsNumber; i++)
- record->append(sqlQuery.value(i).toString());
- results.append(record);
- }
- for (int i(0); i < results.count(); i++)
- qDebug() << "result: " << *results.at(i);
- MarbleWidget w;
- w.show();
- return a.exec();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement