QT on iOS8 with Xcode 6 cannot save files [solved]



  • Hi guys..

    I update QT5.3.2 with Xcode 6 on Macbook, and run my apps on iPad with iOS8.

    I cannot save files on iPad.
    Before this update, I'm using QT5.3.1 with Xcode 5.1, and run my app on iPad with iOS7 is just fine.

    Saving file directory is "../Documents/myFiles.db"

    Would someone give me a hand. Thanks.



  • Hi

    the problems is that the directory is somewhere else

    use this to find out and should work in any devices

    @QString homeLocation = QStandardPaths::locate(QStandardPaths::DocumentsLocation, QString(), QStandardPaths::LocateDirectory);
    QString filename=homeLocation+"acc.txt";
    tf.setFileName(filename);
    tf.open(QIODevice::ReadWrite);
    @

    cheers
    ed



  • Hi, Eduneb

    Thank you for very fast help.

    I fellow your example, it's really work.

    But in my case, using SQLite function for create db file, it's not work.

    Post my simple code above, this simple work fine in the older version of Xcode.

    QSqlDatabase thisDB;
    
    QString homeLocation = QStandardPaths::locate(QStandardPaths::DocumentsLocation, QString(), QStandardPaths::LocateDirectory);
    QString dbName=homeLocation+"SYSTEM.DB3";
    thisDB.close();
    thisDB = QSqlDatabase::addDatabase("QSQLITE",dbName);
    if (thisDB.open() == true) {
        return thisDB.isValid();
    }
    qDebug() << "lastError:" << thisDB.lastError();
    

    It can't create dbName file (SQLite spec).



  • Sorry everyone, I have solved this problem.

    I change my code:

    Before:
    thisDB = QSqlDatabase::addDatabase(“QSQLITE”,dbName);

    After:
    thisDB = QSqlDatabase::addDatabase("QSQLITE");
    thisDB.setDatabaseName(dbName);

    It just work by now. Thank you.


Log in to reply
 

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