Questions tagged [qdir]

A QDir is a class from the Qt toolkit which provides access to directory structures and their contents.

A QDir is used to manipulate path names, access information regarding paths and files, and manipulate the underlying file system. It can also be used to access Qt's resource system.

The official documentation can be found here for Qt 4.8 and here for Qt 5.

84 questions
2
votes
3 answers

[Qt][Linux] List drive or partitions

How I can list drives or mounted partitions using qt? I tried to use: foreach( QFileInfo drive, QDir::drives() ) { qDebug() << "Drive: " << drive.absolutePath(); } but it shows just root drive. I also noticed that length of…
ahaw
  • 221
  • 2
  • 10
2
votes
1 answer

Fail to rename a file in Qt with QDir::rename()

I'm using QDir::rename() to rename a temporary file. here's my code: // change the temporary filename void save::finish() { QString newpath = ui->path->text(); QString newname = ui->filename->text(); newpath.append("/"); …
SamuelNLP
  • 4,038
  • 9
  • 59
  • 102
2
votes
1 answer

QDir information changed

I have a Qt application that creates a qtreeview based on the information of a QDir. Is there a way that if the information on the directory changes (say i add a new file or remove an existing one), the qtreeview is updated? Thanks! =)
acerqueiro
  • 29
  • 5
1
vote
1 answer

How to find and remove bad or dead symbolic links using qt and c++

On a linux machine, I have a folder where I create many other folders dynamically inside it, and some of these folders have a symlink as well: Example: root@system:/run/media/data# ll total 0 lrwxrwxrwx 1 root root 20 Aug 18 17:36 DATA1 ->…
DEKKER
  • 877
  • 6
  • 19
1
vote
0 answers

QFileDialog:Recursive selecting files for unzip

I want to use 7za.exe as a subprocess in qt application, select a root directory using the browse button, look for all .zip and .7z files and extract their content. Now with the code I came up I am unable to recursively select any .zip or .7z in…
1
vote
1 answer

QDir entryList function strange behavior

I'm using VS2019, Qt 5.15.2 I'm using entryList method of the class QDir on the following directory: The following behavior of the entryList method with the QDir::NoDotAndDotDot parameter is strange: tTe following example is self explanatory: My…
1
vote
0 answers

Failure to return file paths in server 2008 qt QDirIterator

I want to see the whole path of a drive, I did it on Windows 8 and 9, the paths are displayed correctly. But in Windows 2003 and 2008, the paths are not displayed, what's the problem? My code #include #include int…
MrErfan
  • 81
  • 6
1
vote
1 answer

QT How to access specific directory within subdirectories with a QDirIterator?

I have thousands of files to go through with a directory structure like this: YYYY_MM_DD XXX XXX XXX Target .hdr files XXX XXX more .hdr files but do not want to process YYYY_MM_DD XXX XXX XXX …
Sailanarmo
  • 1,139
  • 15
  • 41
1
vote
1 answer

Open local HTML file from code in Qt on Mac OSx

Hello i am facing a small issue with Qt on the Mac OSX. So in my program i am trying to open a local .html file located in the same path as the application. Given that Qt is cross-platform , my attempt worked for both Windows and Ubuntu and i…
Noopty
  • 167
  • 2
  • 12
1
vote
1 answer

How to use nameFilters with QDirIterator?

In PySide, when I use QDirIterator, how I can filter on files by name? In the documentation, it talks about the parameter nameFilters: https://srinikom.github.io/pyside-docs/PySide/QtCore/QDirIterator.html But when I try it, it doesn't filter the…
JuanPablo
  • 23,792
  • 39
  • 118
  • 164
1
vote
1 answer

QDirModel setNameFilters hides folders

I want to have a QDirModel that contains both folders and files (so I am using AllEntries). The problem is that when I am calling setNameFilters() on my QDirModel, I'll loose all the folders. Is there any way that I can exclude folders from…
willy
  • 487
  • 5
  • 21
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
vote
1 answer

QDir is giving correct files, but shows inncorrect amount

In my Qt program, I basically choose a folder, view the contents, and then get the indexed list (0, 1, 2, 3, ........). It shows the correct files (left), but converts more than wanted. Here is and image of the error and code: MainWindow.h: #ifndef…
Nicholas Johnson
  • 1,012
  • 2
  • 12
  • 35
1
vote
2 answers

QDir currentPath and cd() not working?

I am currently attempting to create a new directory and create a new file inside of this directory. However, QDir recognizes that this file exists, however when I try to cd to my new directory, the currentPath returns the same value before and after…
138
  • 554
  • 5
  • 14
1
vote
1 answer

Creating a directory with a name containing UTF-8 characters in Qt

I am trying to create a directory that contains a UTF-8 characters using QDir::mkpath . A directory is created but the name is not correct. I am using this sample code: #include #include int main(int argc, char *argv[]) { …