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

Recommended way of passing file paths in Qt application

in the codebase (C++ and Qt5) I am working on, filepaths are passed as QString parameters most of the time. In some cases it is also a combination of QDir and QString. Examples: void foo(const QString &filename); void foo(const QDir pathToFile,…
Christian
  • 31
  • 3
2
votes
1 answer

Validate if editable QCombobox input is a directory via QValidator

I try to validate if a editable QCombobox input is a directory or not before it gets added to the QCombobox. from PySide import QtGui, QtCore class DirValidator(QtGui.QValidator): def __init__(self, cb_input): super(DirValidator,…
zwusel
  • 171
  • 12
2
votes
2 answers

Qt: How to find the nearest existing ancestor of a path, which itself may or may not exist

Motivating example: In a previous session, the application has stored some path selected by the user. In the meantime that path may have been deleted, moved, renamed or the drive unmounted. The application would now like to let the user…
Parker Coates
  • 8,520
  • 3
  • 31
  • 37
2
votes
1 answer

How can QDir::makeAbsolute() fail?

The documentation for QDir::makeAbsolute() says Converts the directory path to an absolute path. If it is already absolute nothing happens. Returns true if the conversion succeeded; otherwise returns false. It's not clear to me how the creation of…
Parker Coates
  • 8,520
  • 3
  • 31
  • 37
2
votes
1 answer

Why QDir::exists() do not work in docker container?

The following program executed in my host KDE Neon machine (up to date upgraded to 18.04) outputs Hello World! 1 as expected while it outputs Hello World! 0 when executed from a Docker container built using the Dockerfile below and running with sudo…
Kleag
  • 642
  • 7
  • 14
2
votes
1 answer

Unsorted Qt containers

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

Is it possible to stop moving file performed by function QDir::rename in Qt?

I have created new thread, that performs moving file from one directory to other with function bool QDir::rename(const QString & oldName, const QString & newName) Is it possible to interrupt this moving ?
FDd
  • 21
  • 1
2
votes
1 answer

How to fast count large set of files

As I have to process a large number of files, I'd like to show a progress of this process. I know that iterating using QDirIterator::next() is the best option, but first I need to know the total number of files in a directory (and all its…
paws
  • 197
  • 1
  • 2
  • 13
2
votes
1 answer

What is the implementation of QDir::count()

All over the internet it seems the accepted way of getting a directory's child count is to loop through its entries manually and count them. This seems far too tedious and generally there are other frameworks and API's that offer a convenience…
Joey Carson
  • 2,973
  • 7
  • 36
  • 60
2
votes
2 answers

Display and read all files in directory

I am trying to print out the file names of all files in a directory. However some files do not show up or cannot be opened. If I restart the program, the files that previously couldn't be opened are in fact opened and displayed. What is going…
Quaxton Hale
  • 2,460
  • 5
  • 40
  • 71
2
votes
2 answers

QDir absolutePath on Mac

Im getting two different paths when i run the same build within Qt Creator and when I double click on it from the Finder on a Mac. Here is my code: QDir dir = QDir::currentPath(); dir.cdUp(); dir.cdUp(); dir.cdUp(); QString rootPath =…
adviner
  • 3,295
  • 10
  • 35
  • 64
2
votes
2 answers

QT - copying a file to AppData

My program prompts the user to select a file to process. My program processes it and it tries to save the file to AppData. This is how I do it: QSettings settings(QSettings::IniFormat, QSettings::UserScope, "FlameTool", "FlameTool"); addin_path =…
movildima
  • 37
  • 1
  • 9
2
votes
2 answers

Windows-Autostart: Application directory seems to be C:/Windows/system32/

When my app is started from the autostart of Windows, Qt is not able to open it. The error that causes this is that QDir().absoluteFilePath("settings.cnf") returns the path C:/Windows/system32/settings.cnf even though my file is located in my…
ThunderStorm
  • 766
  • 8
  • 24
2
votes
1 answer

PyQt iterate over a a QTreeView with checkbox

i am trying to make a UI that display folders from a given directory, and the user can check or uncheck the folder. i would like to get the information of what was checked and return the folder i know i can loop / iterate in a QTableWidget, but if…
pelos
  • 1,744
  • 4
  • 24
  • 34
2
votes
1 answer

What is the best way to decompose a QDir into a QStringList

I am trying to turn a QDir which can contain relative or absolute paths into a list of folders in a QStringList like this: const QString path = dir.path (); return path.split (QRegExp ("[\\/]+"), QString::SkipEmptyParts); This ideally would turn a…
cppguy
  • 3,611
  • 2
  • 21
  • 36