当前位置:网站首页>QT connects two qslite databases and reports an error qsqlquery:: exec: database not open
QT connects two qslite databases and reports an error qsqlquery:: exec: database not open
2022-07-29 07:41:00 【CSDN Q & A】
QT Connect two qslite An error is reported when there is a data connection problem in the database QSqlQuery::exec: database not open
Two databases are two different interfaces , This is the code of one of the databases
Main function program
QSqlDatabase m_db=QSqlDatabase::addDatabase("QSQLITE","material_connect");
m_db.setDatabaseName("E:\Damage-assessment\software\QT\GUI\GUI4.0\gui1.0\build-gui-Desktop_Qt_5_14_2_MSVC2017_64bit-Release\mental_material.db");
if(m_db.open()) { qDebug()<<"open success1"; } else { qDebug()<<"open failed1"; } QSqlQueryModel *model=new QSqlQueryModel(this); QString sql; sql="select name as full name ,density as density , shear_modulus as shear modulus ,yield_stress as Yield stress , maximum_yield_stress as Maximum yield stress , melting_temperature as Melting temperature from mental_material"; model->setQuery(sql,m_db); ui->display->setModel(model); Click the slot function of the button
void material::on_show_pushButton_clicked()
{
QSqlQueryModel *model=new QSqlQueryModel;
QString sql;
sql="select name as full name ,density as density , shear_modulus as shear modulus ,yield_stress as Yield stress , maximum_yield_stress as Maximum yield stress , melting_temperature as Melting temperature from mental_material";
model->setQuery(sql,m_db); ui->display->setModel(model);}
Operation results and error reporting contents
This is the picture after running

But click the display button , The database is gone

Report errors QSqlQuery::exec: database not open
边栏推荐
- Monitor the bottom button of page scrolling position positioning (including the solution that page initialization positioning does not take effect on mouse sliding)
- Use custom annotations to verify the size of the list
- Embroidery of little D
- 09 bloom filter
- 【暑期每日一题】洛谷 P6320 [COCI2006-2007#4] SIBICE
- zip gzip tar压缩进阶版
- 在js中,0表示false,非0表示true
- The new generation of public chain attacks the "Impossible Triangle"
- MySQL 45 talk | 07 line lock merits and demerits: how to reduce the impact of line lock on performance?
- NLP introduction + practice: Chapter 5: using the API in pytorch to realize linear regression
猜你喜欢

【MYSQL】-【子查询】

分析25个主要DeFi协议的路线图 预见DeFi未来的七大趋势

Zero technology is deeply involved in the development of privacy computing financial scenario standards of the ICT Institute

Sqlmap(SQL注入自动化工具)
![[summer daily question] Luogu p6461 [coci2006-2007 5] trik](/img/bf/c0e03f1bf477730f0b3661b3256d1d.png)
[summer daily question] Luogu p6461 [coci2006-2007 5] trik

STM32 operation w25q256 w25q16 SPI flash

Halcon installation and testing in vs2017, DLL configuration in vs2017

Pat class a 1146 topology sequence

Sort out the two NFT pricing paradigms and four solutions on the market

NFT 的 10 种实际用途
随机推荐
You study, I reward, 21 day learning challenge | waiting for you to fight
10 practical uses of NFT
Female graduate students do "mind mapping" and quarrel with their boyfriend! Netizen: the "king of infighting" in the quarrel
SEGGER 的硬件异常 分析
分析25个主要DeFi协议的路线图 预见DeFi未来的七大趋势
Dilworth 定理
Using C language to skillfully realize the chess game -- Sanzi chess
PAT甲级 1146 拓扑顺序
Thinkphp6 realizes database backup
【暑期每日一题】洛谷 P7760 [COCI2016-2017#5] Tuna
UPC little C's King Canyon
Introduction and introduction of logback
你学习·我奖励,21天学习挑战赛 | 等你来战
Go 事,如何成为一个Gopher ,并在7天找到 Go 语言相关工作,第1篇
Monitor the bottom button of page scrolling position positioning (including the solution that page initialization positioning does not take effect on mouse sliding)
小D的刺绣
Pat class a 1150 traveling salesman problem
在js中,0表示false,非0表示true
QT topic: basic components (button class, layout class, output class, input class, container class)
状态机dp三维