回答

收藏

QSqlDatabasePrivate :: removeDatabase:连接“ myConnectionName”仍在使

技术问答 技术问答 489 人阅读 | 0 人回复 | 2023-09-12

我有一个文件夹,里面有很多数据库。有时可以删除数据库或将数据库添加到文件夹中。因此,我使用它QTimer并读取所有数据库。) o- i" _6 F; J8 f* D+ b( b# H
这是我的代码:) C  }' U0 t* Q7 F6 b9 H
this->timer = new QTimer(this);this->timer->setInterval(15000);connect(this->timer,&QTimer::timeout,this,[=]()      QString path = "C:\\Users\\User\\Desktop\\DAXI SMS SENDER\\SMSSenderAllBASE";   QString path = qApp->applicationDirPath()   "\\SMSSenderAllBASE";    QDir recoredDir(path);    QStringList allFiles = recoredDir.entryList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden  | QDir::AllDirs | QDir::Files,QDir:irsFirst);    for (int i = 0; i run();this->timer->start();是的,我肯定会出现helperFinished这次我将与基准站无关。5 F! D5 b; V! n$ z* O
编辑:    如果我删除 7 d% ^* h& d; M2 I
            thrdHelperSendSMS *help = new thrdHelperSendSMS(db,this);   connect(help,&thrdHelperSendSMS::helperFinished,this,[=](QString connectionName){        QSqlDatabase t_db = QSqlDatabase::database(connectionName);       t_db.close();;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QSqlDatabase::removeDatabase(connectionName);       delete help;   });   help->run();例子:
& k9 ]" U) i, q% H0 ]for (int i = 0; i 我也有同样的错误。
4 Z3 b8 c( Y) [# c                                                                2 L2 A  R9 c) n7 d- z$ M  x% Y3 Q7 O
    解决方案:
分享到:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则