SQLITE-ARM-QT编程入门
来源:互联网 发布:minecraft编程 编辑:程序博客网 时间:2024/04/28 17:58
1.我是先用终端在PC上建立数据库和表
2.在PC上编写QT程序
#include <QtGui/QApplication>#include "mainwindow.h"#include <QtSql/QtSql>int main(int argc, char *argv[]){ QApplication a(argc, argv); MainWindow w; QSqlDatabase db; db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("test"); if(db.open()) qDebug()<<"db open successed!"; w.show(); return a.exec();}
xxx.pro
#-------------------------------------------------## Project created by QtCreator 2012-10-05T20:37:35##-------------------------------------------------QT += core guiTARGET = sqlitetestTEMPLATE = appSOURCES += main.cpp\ mainwindow.cppHEADERS += mainwindow.hFORMS += mainwindow.uiQT += sql
#ifndef MAINWINDOW_H#define MAINWINDOW_H#include <QMainWindow>#include <QtSql/QtSql>#include <QTableView>#include <QDebug>namespace Ui { class MainWindow;}class MainWindow : public QMainWindow{ Q_OBJECTpublic: explicit MainWindow(QWidget *parent = 0); ~MainWindow();private slots: void on_pushButton_clicked();private: Ui::MainWindow *ui;};#endif // MAINWINDOW_H
#include "mainwindow.h"#include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this);}MainWindow::~MainWindow(){ delete ui;}void MainWindow::on_pushButton_clicked(){ QSqlQuery query; if(query.exec("select *from test")) qDebug()<<"select successed!"; static QSqlQueryModel model; QString cmd; cmd = "select *from test"; model.setQuery(cmd); ui->tableView->setModel(&model);}
3.运行效果
4.编译到ARM上运行
5.参考资料:
- SQLITE-ARM-QT编程入门
- ARM QT sqlite 解决方案
- ARM QT sqlite 解决方案
- 详解QT Sqlite ARM 编写程序实例
- ARM串口编程入门
- qt中SQLite数据库编程
- 基于Qt的sqlite编程
- Qt数据库SQLITE编程Demo
- QT编程入门
- QT编程入门
- qt编程入门
- QT编程初步入门
- 【Qt编程】- 入门
- qt qtcpserver编程入门
- qt quick 入门编程
- qt界面编程入门
- linux qt中sqlite入门操作
- qt编程使用sqlite存储读取文件
- sqlite3移植到ARM SQLITE3.7.14
- ARM上linux终端操作SQLITE,退格键问题
- SQLite header and source version mismatch
- Qt CREATOR快捷键
- SQLITE3在PC机ubuntu上的安装
- SQLITE-ARM-QT编程入门
- ubuntu11.04下使用USB转串口-minicom
- QT线程编程-串口收发
- 自定义Windows XP的打开窗口 文件选择框-无需第三方软件
- v4l
- ubuntu添加终端到右键
- linux下find命令查找文件夹
- Qt 自带的函数和引用的外部库函数名冲突
- Qt获取激光扫描枪的数据