QSqlQuery in MacOS



  • One code for Windows and Macos. In Windows - ok, in Macos I get the following error
    "unable to fetch row" - what the Reason?

        QDir dir(qApp->applicationDirPath());
        #if defined(Q_OS_MAC)
            dir.cd(QFile::decodeName("../Resources"));
        #endif
        QString fileName = dir.absolutePath()+"/ReloadingStudio.db";
    
        auto db = QSqlDatabase::addDatabase("QSQLITE");
        db.setDatabaseName(fileName);
        if (!db.open())
            qWarning() << db.lastError().text();
    
        auto codec = QTextCodec::codecForName("UTF8");
        QTextCodec::setCodecForLocale(codec);
    
        sqlStr = "select cs_id, cs_brand, cs_chambered from cases;";
    
        QSqlQuery query(sqlStr);
        query.exec();
        if (query.lastError().type() != QSqlError::NoError)
            qWarning() << query.lastError().text();
    

  • Lifetime Qt Champion

    Hi,

    What problem did you had ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.