qfile

Qt cannot cannot create/write to C:\\

落爺英雄遲暮 提交于 2019-12-01 06:07:15
I am writing a Qt program (4.7 for windows 7 initially) that requires writing to the installed directory (C:\Program Files...). No files are being created when I try to write to a location that would be "protected" (program files, C:\ etc). However, QFile is not giving me any error code (error() is returning 0 which means it worked fine). Here is a code snippit that I am using that is not working. I am closing the file its just much later in the program. QApplication a(argc, argv); // Setting plugin paths. QStringList paths = QCoreApplication::libraryPaths(); paths.append(QCoreApplication:

How to create a new File with full path in Qt?

拈花ヽ惹草 提交于 2019-11-30 21:49:59
问题 I am a Qt beginner and just got stuck with the problem. I am looking for a file SomePath/NewDirectoryA/NewFile.kml ( NewFile.kml will be the only file in NewDirectoryA , having this directory just to maintain semantics in the project). If SomePath/NewDirectoryA/NewFile.kml exists then I will use it in my code and if it doesn't exist then I have to create it. If this File doesn't exist then this directory also doesn't exist in SomePath . So If only I have to create a file I can use QFile and

QFile.write( myStruct ) - how?

风流意气都作罢 提交于 2019-11-29 17:36:34
I'm beginning with Qt and am stuck with a problem supposedly for quite a long time now. I'm sure it's just something I don't see in C++. Anyway, please look at the following simple code and point me what am I doing wrong: typedef struct FILEHEADER { char udfSignature[8]; char fileName[64]; long fileVersion; UNIXTIME fileCreation; UNIXTIME lastRebuild; FILEPOINTER descriptor; } fileheader; QFile f("nanga.dat"); if(f.open(QIODevice::ReadWrite)); f.write(fileheader); Qt 5.2.0 trows me the following error message: C:\sw\udb\udb\main.h:113: error: no matching function for call to 'QFile::write

QFile.write( myStruct ) - how?

时间秒杀一切 提交于 2019-11-28 10:29:37
问题 I'm beginning with Qt and am stuck with a problem supposedly for quite a long time now. I'm sure it's just something I don't see in C++. Anyway, please look at the following simple code and point me what am I doing wrong: typedef struct FILEHEADER { char udfSignature[8]; char fileName[64]; long fileVersion; UNIXTIME fileCreation; UNIXTIME lastRebuild; FILEPOINTER descriptor; } fileheader; QFile f("nanga.dat"); if(f.open(QIODevice::ReadWrite)); f.write(fileheader); Qt 5.2.0 trows me the

Qt create Link between folders

安稳与你 提交于 2019-11-28 05:19:46
问题 I have to build a small dialog that creates a symbolic link to a folder. In windows I would use mklink /D command. Is there a possibility to create such links in Qt? I have only seen QFile creating links between files and that they need to end with .lnk (http://qt-project.org/doc/qt-4.8/qfile.html#link) QDir on the other hand does not provide anything. Any suggestions? Best regards, Richard 回答1: Is there a possibility to create such links in Qt? Yes, it is, but only on Unix. Unfortunately,

Open QFile for appending

你。 提交于 2019-11-27 09:40:28
How can I open a QFile for appending, i.e. the equivalent of FILE *f = fopen("myfile.txt", "a"); Maciej Open the file in QIODevice::Append mode: QFile f(...); if (f.open(QIODevice::WriteOnly | QIODevice::Append)) { ... } See also the documentation . 来源: https://stackoverflow.com/questions/13856734/open-qfile-for-appending

Parsing through a csv file in Qt

 ̄綄美尐妖づ 提交于 2019-11-27 02:44:30
问题 Is anyone familiar with how to parse through a csv file and put it inside a string list. Right now I am taking the entire csv file and putting into the string list. I am trying to figure out if there is a way to get only the first column. #include "searchwindow.h" #include <QtGui/QApplication> #include <QApplication> #include <QStringList> #include <QLineEdit> #include <QCompleter> #include <QHBoxLayout> #include <QWidget> #include <QLabel> #include <qfile.h> #include <QTextStream> int main

Open QFile for appending

孤街浪徒 提交于 2019-11-26 14:48:26
问题 How can I open a QFile for appending, i.e. the equivalent of FILE *f = fopen("myfile.txt", "a"); 回答1: Open the file in QIODevice::Append mode: QFile f(...); if (f.open(QIODevice::WriteOnly | QIODevice::Append)) { ... } See also the documentation. 来源: https://stackoverflow.com/questions/13856734/open-qfile-for-appending

Non-blocking worker - interrupt file copy

天涯浪子 提交于 2019-11-26 02:14:37
问题 I\'m dealing with very large files, in excess of hundreds of GB in size. The User needs to be able to move these files between disks and is on a restricted system with no default file manager. It\'s possible for the User to realize they\'ve made a mistake and cancel the operation, and as far as I can tell the User will have to wait for the current copy or rename operation to complete. This can leave them feeling frustrated as they wait potentially minutes, only to see that their many GB file