Questions tagged [qfileinfo]

In the QT platform, the QFileInfo class provides system-independent file information.

The QFileInfo class provides system-independent file information.

QFileInfo provides information about a file's name and position (path) in the file system, its access rights and whether it is a directory or symbolic link, etc. The file's size and last modified/read times are also available. QFileInfo can also be used to obtain information about a Qt resource.

http://qt-project.org/doc/qt-5/qfileinfo.html

30 questions
23
votes
2 answers

Get relative path from a file in Qt

I am trying to get the relative path from files that I would like to write. Here a situation: I save a conf file in D:\confs\conf.txt. I have in my programs some files read from D:\images\image.bmp. In my conf.txt I would like to have…
user3627590
  • 281
  • 1
  • 4
  • 10
7
votes
2 answers

How to move a file to another existing directory in Qt

I am a beginner in Qt, one part of my project is moving a existing file to another existing directory? Can someone gives me a specific example? I am not sure whether I should use Qfile::rename(). I try write like…
innocent boy
  • 315
  • 4
  • 13
5
votes
1 answer

Set file owner:group in Linux using Qt/C++

I need to change the owner and group of a file under Linux using Qt 5.7 /C++. I found the QFileInfo::ownerID and QFileInfo::groupID getters, but there appear to be no setters for these values. I need the Qt equivalent of chown. Is there a way to…
TSG
  • 4,242
  • 9
  • 61
  • 121
4
votes
2 answers

Qt's QDir: File Names Dropping Non-Ascii Characters

I am having issues with QDir losing Non-Ascii characters from my file names. I have files with names like testingöäüß.txt or exampleΦ.shp and when trying to use Qt utilities like QDir and QFile they simply show up as testing.txt and example.shp.…
cheddarhead52
  • 61
  • 1
  • 4
3
votes
2 answers

Porting from Glib to Qt

I am porting an application from Glib to Qt. I do have a lot of API specific to Gtk, but it's difficult to find the equivalent variants in Qt. I am looking for the alternative of these: g_path_get_basename g_path_get_dirname strdup Any idea?
Seb
  • 2,929
  • 4
  • 30
  • 73
3
votes
1 answer

last modified date of file in Qt resource system

Normally you can get last modified date easily with QFileInfo::lastModified(). However this doesn't work when a file inside Qt's resource system is used QFileInfo resourceInfo("://resource.txt"); qDebug() << resourceInfo.lastModified().toString() //…
Hedge
  • 16,142
  • 42
  • 141
  • 246
2
votes
2 answers

QFileInfo size() is returning shortcut TARGET size

I am scanning folder size like this: qint64 dirSize = 0; int fileCount = 0; for(QDirIterator itDir(someDir, QDir::NoDotAndDotDot|QDir::Files|QDir::Hidden|QDir::System, QDirIterator::Subdirectories); itDir.hasNext(); ) { …
bur
  • 604
  • 5
  • 20
2
votes
1 answer

Unsorted Qt containers

I have a QVector, which should store filepaths,…
Sayan Bera
  • 135
  • 2
  • 16
2
votes
1 answer

getOpenFileName - preselect last opened not working

In my application I need to load many images. I would really use an option to select the last opened file, so I would like to know the last selected file. Documentation says: QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), …
Pawel
  • 169
  • 1
  • 12
2
votes
1 answer

Trigger signal when file size limit is reached

I'm writing log files and would like to set a size limit of 10 Mo. I was thinking of setting a QTimer triggering every X minutes/hours QFileInfo::refresh and checking the size of the file. Would there be a better way to do this? Using a QTimer…
Grégoire Borel
  • 1,880
  • 3
  • 33
  • 55
2
votes
1 answer

How to get the file version in Qt?

How to get the file version from File properties\Details\File version in Qt? I didn't find it in QFileInfo.
Hurr
  • 55
  • 1
  • 8
1
vote
0 answers

Adjust copied file's QDateTime to that of the source file

Context: I have an application that searches files in a directory(s)and copies specific files. Problem: Using FileCopyExW, I copy the file(s) successfully to the new location, however the file's date and time to not match, it may be off by a second…
CybeX
  • 2,060
  • 3
  • 48
  • 115
1
vote
1 answer

PyQt5 set qt_ntfs_permission_lookup

I want to use isWritable() from QFileInfo. According to the docs, you have to somehow set qt_ntfs_permission_lookup to 1 to get a meaningful result on Windows. The C++ code for this is extern Q_CORE_EXPORT int…
bfris
  • 5,272
  • 1
  • 20
  • 37
1
vote
0 answers

Getting a file icon solely from a given MIME-type (no file itself) in Qt

Ok, I know about the class QFileIconProvider. I also know about QMimeType (and QMimeDatabase). But I am surprised that I cannot find a simple connection between the two. So what I need is to get an icon used by the operating system for a given type…
Maximko
  • 627
  • 8
  • 20
1
vote
1 answer

How to Search a file in QDir

I am developing an Application for MAC OS X. In which I have to find files in folder. Problem is that I want to give comfort, to user, to search a file by entering a QString. This QString may be the exact name of file or a text contain in the file…
Rohit Chauhan
  • 151
  • 1
  • 3
  • 14
1
2