QT on iOS8 with Xcode 6 cannot save files [solved]
-
wrote on 26 Sept 2014, 02:44 last edited by
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.
-
wrote on 26 Sept 2014, 04:39 last edited by
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 -
wrote on 26 Sept 2014, 05:20 last edited by
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).
-
wrote on 26 Sept 2014, 05:29 last edited by
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.
1/4