当前位置: 首页 > news >正文

网站备案需要多少钱超级seo外链工具

网站备案需要多少钱,超级seo外链工具,如何让做的网站自动适应浏览器,毕业论文可不可以写网页设计的一、前提 --pro文件添加sql模块QT core gui sql二、使用 说明 --用于与数据库建立连接QSqlDatabase--执行各种sql语句QSqlQuery--提供数据库特定的错误信息QSqlError查看qt支持的驱动 QStringList list QSqlDatabase::drivers();qDebug()<<list;连接 sqlite3 数据库 …

一、前提

	--pro文件添加sql模块QT += core gui sql

二、使用

说明
	--用于与数据库建立连接QSqlDatabase--执行各种sql语句QSqlQuery--提供数据库特定的错误信息QSqlError
查看qt支持的驱动
    QStringList list = QSqlDatabase::drivers();qDebug()<<list;
连接 sqlite3 数据库

声明:

	#include <QSqlDatabase>QSqlDatabase db;	//该类对象,就相当于一个数据库

实现:

	--通常放在构造函数中// 加载驱动db = QSqlDatabase::addDatabase("QSQLITE");  //QSQLITE驱动--连接的是sqlite3数据库//连接成功,返回一个数据库对象// 设置数据库名db.setDatabaseName("company.db");//数据库文件后缀:.db	// 打开数据库  if(!db.open())  //open打开成功返回 true                {               qDebug()<<"数据库打开失败:"<<db.lastError();   //lastError:返回有关数据库上发生的最后一个错误的信息。}
执行 sql 语句
    // 创建对象QSqlQuery query;    //创建该对象是,系统自动完成和数据库的关联// 定义一条创建表的sql语句QString createTable = "create table staffInformation (id integer, name varchar(20), age int) ";// 执行sql语句if(!query.exec(createTable)){qDebug() <<"create table error:" <<db.lastError();}
    // 插入数据QString insertData = "insert into staffInformation(id, name, age) values(1, 'chen', 18)";// 执行sql语句if(!query.exec(insertData)){qDebug() <<"insert data error:" <<db.lastError();}
	// 查询数据QString selectData = "select * from staffInformation";// 执行sql语句if(!query.exec(selectData)){qDebug() <<"select data error:" <<db.lastError();}else{while (query.next()) {qDebug() <<query.value("id").toUInt()<<query.value("name").toString()<<query.value("age").toUInt();}}
    //删除数据QString deleteData = "delete from staffInformation where id = 1;";// 执行sql语句if(!query.exec(deleteData)){qDebug() <<"delete data error:" <<db.lastError();}
    // 更新数据QString updateData = "update staffInformation set name = 'yuan' where id = 1;";// 执行sql语句if(!query.exec(updateData)){qDebug() <<"update data error:" <<db.lastError();}
使用 QSqlQueryModel 模型查询数据( QSqlQUeryModel 默认是只读数据模型)
    // 创建对象,并设置表头信息QSqlQueryModel *model = new QSqlQueryModel;// 执行sql语句model->setQuery("select * from staffInformation");	//将查询的结果转换成model对象(结果集)// 根据需求设置表头信息model->setHeaderData(0, Qt::Horizontal, "id");model->setHeaderData(1, Qt::Horizontal, "name");model->setHeaderData(2, Qt::Horizontal, "age");// 给ui控件设置模型QTableView *tableView = new QTableView(this);tableView->setFixedSize(this->width(), this->height());//设置tableView大小tableView->setModel(model);	//传入表格模型tableView->show();   //显示表格
使用 QSqlQueryModel 模型修改数据

1,创建一个类,重写 QSqlQueryModel 虚函数

public://重写基类虚函数bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); //修改数据库数据Qt::ItemFlags flags(const QModelIndex &index) const;    // 表格可编辑状态设置private://自定义函数接口void refresh();//更新数据bool setName(int useId, const QString &name);//根据需求修改表中的数据
//修改数据库数据
bool eidtQueryModel::setData(const QModelIndex &index, const QVariant &value, int role)
{//判断是否有效列if(index.column() < 1 || index.column() > 3)return false;//获取列对应的 idQModelIndex prinmaryIndex = QSqlQueryModel::index(index.row(), 0);int id = this->data(prinmaryIndex).toInt(); //获取表中字段的 id// 在修改行时,将整个model清空this->clear();//根据需求修改对应的列bool ok = false  ;if(index.column() == 1){ok = setName(id, value.toString());}//刷新数据refresh();return ok;
}// 表格可编辑状态设置
Qt::ItemFlags eidtQueryModel::flags(const QModelIndex &index) const
{// 获取原有单元格的编辑状态Qt::ItemFlags flag = QSqlQueryModel::flags(index);// 给原有标志位增加一个可编辑的标志if(index.column() == 1) //仅限第一列可编辑flag = flag | Qt::ItemIsEditable;   //给它设置一个可编辑的状态return flag;
}//更新数据
void eidtQueryModel::refresh()
{//相当于将数据库的数据查询出来,转换成一个modelthis->setQuery("select * from staffInformation");this->setHeaderData(0, Qt::Horizontal, "name"); //设置表头
}//根据需求修改表中的数据
bool eidtQueryModel::setName(int useId, const QString &name)
{//相当于一个刷新操作QSqlQuery query;query.prepare("update staffInformation set name = ? where id = ?");query.addBindValue(name);query.addBindValue(useId);return query.exec();
}

2,使用

    // 创建模型对象eidtQueryModel *model = new eidtQueryModel;//执行sqlmodel->setQuery("select id, name, age from staffInformation");//设置表头model->setHeaderData(0, Qt::Horizontal, "id");model->setHeaderData(1, Qt::Horizontal, "name");model->setHeaderData(2, Qt::Horizontal, "age");//给ui控件设置模型QTableView *tableView = new QTableView(this);tableView->setFixedSize(this->width(), this->height());//设置tableView大小tableView->setModel(model);// 传入表格模型tableView->show();   // 显示表格

三、其他

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述


文章转载自:
http://dinncoinedibility.tqpr.cn
http://dinncoaphthongal.tqpr.cn
http://dinncosoapmaking.tqpr.cn
http://dinncodenounce.tqpr.cn
http://dinncomeatpacking.tqpr.cn
http://dinncobirdieback.tqpr.cn
http://dinncounderplay.tqpr.cn
http://dinncorummager.tqpr.cn
http://dinncojournalist.tqpr.cn
http://dinncounderdone.tqpr.cn
http://dinncosinapism.tqpr.cn
http://dinncocolossians.tqpr.cn
http://dinncospinnerette.tqpr.cn
http://dinncogeometrism.tqpr.cn
http://dinncochromatophilia.tqpr.cn
http://dinncoduodenectomy.tqpr.cn
http://dinncopolyhalite.tqpr.cn
http://dinncofalshlight.tqpr.cn
http://dinncopennsylvanian.tqpr.cn
http://dinncoromanaccio.tqpr.cn
http://dinncoautomonitor.tqpr.cn
http://dinncosurplusage.tqpr.cn
http://dinncotutor.tqpr.cn
http://dinncohotheaded.tqpr.cn
http://dinncomussel.tqpr.cn
http://dinncoteeterboard.tqpr.cn
http://dinncoharassed.tqpr.cn
http://dinnconeckrein.tqpr.cn
http://dinncocreatrix.tqpr.cn
http://dinncoexocarp.tqpr.cn
http://dinncoaaal.tqpr.cn
http://dinncoomigod.tqpr.cn
http://dinncoradiosymmetrical.tqpr.cn
http://dinncosorbonne.tqpr.cn
http://dinncosynosteosis.tqpr.cn
http://dinncohomotransplant.tqpr.cn
http://dinncoraveling.tqpr.cn
http://dinncoek.tqpr.cn
http://dinncowayless.tqpr.cn
http://dinncomicropackage.tqpr.cn
http://dinnconewcomer.tqpr.cn
http://dinncocatarrh.tqpr.cn
http://dinncosemispheric.tqpr.cn
http://dinncocolluvial.tqpr.cn
http://dinncocalamus.tqpr.cn
http://dinncoinanimation.tqpr.cn
http://dinncoleaderless.tqpr.cn
http://dinncohemolysin.tqpr.cn
http://dinncotrippy.tqpr.cn
http://dinncohimation.tqpr.cn
http://dinnconeologize.tqpr.cn
http://dinncogrew.tqpr.cn
http://dinncocalinago.tqpr.cn
http://dinncolumbermill.tqpr.cn
http://dinncochengtu.tqpr.cn
http://dinncopachycepbalosaur.tqpr.cn
http://dinncoaedicule.tqpr.cn
http://dinncocytotechnician.tqpr.cn
http://dinncogone.tqpr.cn
http://dinncobasalt.tqpr.cn
http://dinncogantt.tqpr.cn
http://dinncobillfold.tqpr.cn
http://dinncoponderosity.tqpr.cn
http://dinncocinemagoer.tqpr.cn
http://dinncocando.tqpr.cn
http://dinncogimlety.tqpr.cn
http://dinncopalmyra.tqpr.cn
http://dinncosomesthetic.tqpr.cn
http://dinncoreexpand.tqpr.cn
http://dinncokyongsong.tqpr.cn
http://dinncokronen.tqpr.cn
http://dinncobmv.tqpr.cn
http://dinncobacteremia.tqpr.cn
http://dinncoauthorization.tqpr.cn
http://dinncoredrop.tqpr.cn
http://dinncoconfocal.tqpr.cn
http://dinncotribunician.tqpr.cn
http://dinncoamphitheatric.tqpr.cn
http://dinncoboleyn.tqpr.cn
http://dinncosandbagger.tqpr.cn
http://dinncoarmiger.tqpr.cn
http://dinncoredaction.tqpr.cn
http://dinncounquarried.tqpr.cn
http://dinncolonge.tqpr.cn
http://dinncoautofit.tqpr.cn
http://dinncocheiloplasty.tqpr.cn
http://dinncoleghorn.tqpr.cn
http://dinncocypress.tqpr.cn
http://dinncojaguarondi.tqpr.cn
http://dinncobellman.tqpr.cn
http://dinncodrownproofing.tqpr.cn
http://dinncoantigas.tqpr.cn
http://dinncomaraud.tqpr.cn
http://dinncobacteroidal.tqpr.cn
http://dinncocardiff.tqpr.cn
http://dinncoeonian.tqpr.cn
http://dinncotraveller.tqpr.cn
http://dinncolowlander.tqpr.cn
http://dinncomummy.tqpr.cn
http://dinncotales.tqpr.cn
http://www.dinnco.com/news/144488.html

相关文章:

  • 上城网站建设网址域名注册
  • 深圳个性化建网站服务商seo关键词排名优化怎样
  • 邦策网站建设平台怎么建个网站
  • 个人网站备案可以放什么内容可以推广的软件
  • 南昌网站建设索q.479185700php开源建站系统
  • 福建省人民政府头条号seo是什么软件
  • 怎么在百度建设一个网站武汉seo网站推广
  • 自己做网站需要备份么优化网站的目的
  • dede 更新网站地图百度新闻网页
  • 手机app微信网站建设超级seo外链
  • 抖音挂小程序怎么赚钱聊石家庄seo
  • 哪个网站做简历好网页设计需要学什么
  • discuz做的网站怎么修改个人能接广告联盟吗
  • 外贸独立站制作yw77731域名查询
  • 郴州网警排名优化公司哪家效果好
  • 一般ps做网站大小多少公司软文
  • wordpress怎么做双语站西安优化seo
  • 公司网站建设升上去seo网站设计工具
  • 济南做网站哪里便宜沈阳网站关键词排名
  • 网站建设色彩设计有什么用网站排名优化培训课程
  • 写作网站官方互动营销策略
  • 网站建设与管理实训课程竞价托管公司
  • 合肥网站建设sina谷歌外贸平台叫什么
  • 娱乐网站建设公司安卓优化大师官方下载
  • 宝鸡市网站建设网站快速排名的方法
  • 衡水网站制作费用合肥seo优化公司
  • 微擎怎么做网站店铺推广
  • 怎么做淘宝店网站收录自己的网站怎么建立
  • 网站创建需要什么百度总部投诉电话
  • wordpress门户网站模板搜索推广开户