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
25
votes
2 answers

How to concatenate an absolute path and relative path with QDir?

I have a relative path and absolute path that look something like this: Absolute: /tmp/somedir Relative: anotherdir/file.txt I would like to concatenate the two (/tmp/somedir/anotherdir/file.txt) with QDir but I am not quite sure what the proper…
Nathan Osman
  • 71,149
  • 71
  • 256
  • 361
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
16
votes
2 answers

QDir.setNameFilter how to show only files with specific extensions?

setNameFilters isn't working as I would expect, so if anyone can explain if I'm using it incorrectly, or if maybe this is a bug in Qt: Here is my code sample: QDir export_folder("C:\path"); QStringList fileList =…
gollumullog
  • 1,249
  • 2
  • 14
  • 22
7
votes
1 answer

Why is there no static QDir::makepath()?

I know, that to create a new path in Qt from a given absolute path, you use QDir::makepath() as dir.makepath(path), as it is suggested in this question. I do not have any trouble in using it and it works fine. My question is directed, as to why the…
T3 H40
  • 2,326
  • 8
  • 32
  • 43
6
votes
1 answer

QFile::remove not removing file?

Having a strange problem when trying to remove a file i just downloaded with Qt. My code: QString location = "/path/to/app/Application.app"; QFile *rmFile = new QFile(location); rmFile->remove(); File is not being removed. Any ideas what could be…
user3490755
  • 955
  • 2
  • 15
  • 33
5
votes
1 answer

QDir::tempPath() vs QStandardPaths::writableLocation()

I need to get the path to the temporary directory. Is there any difference between the following methods (except for the first one is available in Qt 4)? Which one is better to…
John Doe
  • 555
  • 6
  • 17
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
4
votes
3 answers

Diagnosing QDir::rmdir failure

I’m using the following code to delete an empty folder on Linux: bool removeFolder (const QString& path) { QDir dir(path); assert(dir.exists()); return dir.rmdir("."); } For some reason it sometimes returns false (for specific folders, but…
Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
3
votes
3 answers

QT Multiple item selection from a list of files and folders

I'm developing a Qt C++ application in Unix and I've been trying to do something similar to what this image shows: As you can see, there is a list of files and folders and a user can select multiple of them (if a folder is selected, all childs also…
lpares12
  • 3,504
  • 4
  • 24
  • 45
3
votes
1 answer

QDir mkpath doesn't create directory on android

Every time I launch application, mkpath is called as if the directory was not created previously despite I always get 'path created' log. Do I need to specify any special privileges to save into the internal storage? mypath looks like…
Nadarian
  • 962
  • 9
  • 22
3
votes
2 answers

Copying Directory and sub directory

Hi im try to copy a directory and all its contents. I thought a good start is to list all the sub directories so i can get an idea and copy the sub structure to my destination folder. but i need to get the path from the QDir onwards not the path…
Brett
  • 376
  • 7
  • 24
3
votes
1 answer

Why QDir::rmdir is not static?

QFile has a static function bool QFile::remove ( const QString & fileName ) [static] which deletes the specified file. This is handy: we have a path to file, and we use a command to remove it. However, QDir does not have such command, only this…
ScumCoder
  • 690
  • 1
  • 8
  • 20
3
votes
1 answer

how to get the list of files without their extensions in a specified directory in Qt

i want to get all the files that are located in a specified directory but without their extensions at the end .I did this Qt Code: QDir myDir(mConfigDirectory); filters << "*.ini"; myDir.setNameFilters(filters); list =…
Ibrahim MAATKI
  • 363
  • 4
  • 19
3
votes
1 answer

QDir absolutePath still returning the filename

QString FilePath2 = QFileDialog::getOpenFileName(this, tr("Open Directory"), "C:/", tr("Text files (*.txt)")); QDir a = FilePath2; qDebug() << a.absolutePath(); Code works fine. But absolutePath() is still returning the path + filename instead of…
Blastcore
  • 360
  • 7
  • 19
3
votes
1 answer

QDir::mkPath and Permissions

I am working on Ubuntu 12.04 LTS and 10.04 LTS platforms and I am having a problem with QDir::mkPath. I am trying to create a path using mkPath, lets say /john/play/games and then copy a file game.htm to the /home/john/play. After I copy the file I…
sky
  • 115
  • 2
  • 10
1
2 3 4 5 6