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
0
votes
1 answer

Qt - Auto detection of a file in application folder

I have a sqlite database of my Qt C++ application. Suppose I located it on my default build/release folder and I also placed the database file on that same folder. I have login.h and login.cpp. I want that the application may auto detect the…
user13605962
0
votes
0 answers

QDir::entryList() sorts files when QDir::NoSort flag is set

I have a local directory where some images are stored. The images are named like "1.JPG", "2.JPG", "3.JPG", etc. When i view them through explorer, they are sorted ascending int value in name, i.e "1.JPG" is first, "2.jpg" is second, "3.JPG" is…
George
  • 578
  • 4
  • 21
0
votes
1 answer

How can I call a QDir lib in C++?

I download qt in my computer and called QDir as#include . But it come up with error fatal error: QDir: No such file or directory . Is there anyway to use QDir without creating a .pro file? I tried to create a .pro file: Template += app QT +=…
0
votes
0 answers

QDir::SortFlag memebers available in QML

How can be made available the members of QDir::SortFlag to a QML script? For instance, how to fill up a combo from a QML script with the members of QDir::SortFlag enum or QDir::SortFlags in order to choose some sort criterium? Is this available…
mike
  • 408
  • 5
  • 18
0
votes
1 answer

Qt: What's the difference between remove() and rmdir()

QFileSystemModel* _dirModel = new QFileSystemModel(this); . . _dirModel->rmdir(index); _dirModel->remove(index); "rmdir" seems to be made for removing directories, but I succesfully deleted directory with "remove" as well. What's the point of…
iamalminko
  • 105
  • 8
0
votes
1 answer

Qt get File directory based on directory content

I have few directorates and one file *.txt under one Directory A, Directory path is in QString say c:/A/1/2/3/4 c:B/C/A/1/2/3/4/5/6 In my code I have only the full path, now I want to get the directory until A(name of A can change anytime)…
Sijith
  • 3,740
  • 17
  • 61
  • 101
0
votes
0 answers

Watch new files in a directory with Qt

In my case files permanently are being added into the directory. I need to read names of the files which have the most recently been added into the directory, that is only new files. I'm tracking the directory using QFileSystemWatcher class. But how…
Artem Zefirov
  • 423
  • 5
  • 14
0
votes
0 answers

copy file from resource to disk keeping folder structure (platform independant)

Problem: How do I copy resource files, while preserving file names, to the disk in a platform independent way? Example and Explanation: I have files in my Resource File (.qrc file) e.g.: :/student/stud_temp …
CybeX
  • 2,060
  • 3
  • 48
  • 115
0
votes
2 answers

Qt QDir::current()

I had some code like this: void MainWindow::saveData() { QDir oldDir=QDir::current();//this should return the main executable directory.Since there is no other place in my hole code where i temper with QDir. QDir sess("Sessions"); …
coucou8949
  • 41
  • 1
  • 7
0
votes
3 answers

Find out if file path is mapped / remote or local

Is it possible to find out if a drive path (e.g. P:/temp/foo) is local or remote? Here ( CMD line to tell if a file/path is local or remote? ) it's shown for a cmd evaluation, but I am looking for a C++/Qt way. Related to: QDir::exists with mapped…
Horst Walter
  • 13,663
  • 32
  • 126
  • 228
0
votes
1 answer

Save file in a specific dir with QFile.open and Qdir in qt

I was trying to create/save a file in qt creator with QFile.open(). But it is always creating/saving files in build folder of application. I have tried this code to change the dir to my directory which inside the directory where I have my…
amol01
  • 1,823
  • 4
  • 21
  • 35
0
votes
1 answer

Qt: How to create a file using a path on any Windows machine?

I am not exactly sure if the title captures what exactly I want to ask so here it is: I just made my first desktop application that uses a XML file to store data. The XML File is stored somewhere in C:/Users/myname/Documents/adjsklf/asdjfklasd/....…
KitKat
  • 11
  • 5
0
votes
1 answer

Using Qt's QDirIterator with FTP server

(Using Qt 4.7) I have a function that needs to take a user input of a directory name, then loop through files in a directory by that name on an FTP server. The ftp address is constant so I have it hard-coded in. So far I have this: QString dir_name…
thnkwthprtls
  • 3,287
  • 11
  • 42
  • 63
0
votes
1 answer

Qt4: How to read data from files in a directory using QDirIterator

Using Qt 4.7, I need to look for a file in a given directory that has a certain name. If it is found, I need to get the text data from within that file. I have the code set up as follows: QDirIterator iterator(dir_name,…
thnkwthprtls
  • 3,287
  • 11
  • 42
  • 63
0
votes
2 answers

How to get a complete path from one with wildcards?

I have a path like: C:\path\to\my*file\ and I would like to get the corresponding full path (if it exists): C:\path\to\my1file\ I tried with this Qt code, but the result is the same path I had at the beginning: QStringList filters; filters…
Pietro
  • 12,086
  • 26
  • 100
  • 193