QT's SQLite connection

Source: Internet
Author: User
Tags sqlite

Don't do anything, just press the instructions and write a bunch of code.

QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");

	//open datebase
	db.setDatabaseName("data.db");
	if(!db.open()){
		qDebug()<<"Could not open file!"<<endl;
	}else{
		qDebug()<<"Open file: "<<db.databaseName()<<" sucessfully!"<<endl;
	}
	//creat the date model
	QSqlRelationalTableModel *model;
	model = new QSqlRelationalTableModel(defectDbTableView);
	//set table
	model->setTable("product");
	//select data
	model->select();
	defectDbTableView->setModel(model);

Of course, Brother also

#include <QSqlDatabase>
#include <QSqlRelationalTableModel>

Sister Oh, or say the division did not find the error LNK2019: unresolved external symbol "__declspec (dllimport) public: __thiscall Qsqldatabase, That's not a stupid thing to do. No DLL library or what lib? Well, go and see if there's anything.


This is not everything, OK, to the elder brother personally add, and remember Oh, not add plugin inside these things, two paths remember to look at the picture



All right, compile and pass, wash our asses for Our Lady.



QT's SQLite connection

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.