Related Posts. Leave a Comment Cancel Reply Your email address will not be published. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions. See also currentPath , setCurrent , home , root , and temp. Returns the absolute path of the application's current directory. The current directory is the last directory set with QDir::setCurrent or, if that was never called, the directory at which this application was started at by the parent process.
Returns the name of the directory; this is not the same as the path, e. If the directory has no name e. No check is made to ensure that a directory with this name actually exists; but see exists. See also path , filePath , absolutePath , and absoluteFilePath. On other operating systems, it returns a list containing just one root directory i. See also root and rootPath.
Returns a list of QFileInfo objects for all the files and directories in the directory, ordered according to the name and attribute filters previously set with setNameFilters and setFilter , and sorted according to the flags set with setSorting. The name filter, file attribute filter, and sorting specification can be overridden using the nameFilters , filters , and sort arguments.
Returns an empty list if the directory is unreadable, does not exist, or if nothing matches the specification. The attribute filter and sorting specifications can be overridden using the filters and sort arguments. Returns a list of the names of all the files and directories in the directory, ordered according to the name and attribute filters previously set with setNameFilters and setFilter , and sorted according to the flags set with setSorting.
Note: To list symlinks that point to non existing files, System must be passed to the filter. Unless name contains an absolute file path, the file name is assumed to be relative to the directory itself, so this function is typically used to check for the presence of files within a directory.
Returns true if the directory exists; otherwise returns false. If a file with the same name is found this function will return false. The overload of this function that accepts an argument is used to test for the presence of files and directories within a directory.
Returns the path name of a file in the directory. If the QDir is relative the returned path name will also be relative. The returned string may be the same as the argument on some operating systems, for example on Unix. See also toNativeSeparators and separator.
The directory is constructed using the absolute path of the home directory, ensuring that its path will be the same as its absolutePath. See also drives , current , root , and temp. Under Windows this function will return the directory of the current user's profile. Typically, this is:. Use the toNativeSeparators function to convert the separators to the ones that are appropriate for the underlying operating system. If the directory of the current user's profile does not exist or cannot be retrieved, the following alternatives will be checked in the given order until an existing and available path is found:.
Under non-Windows operating systems the HOME environment variable is used if it exists, otherwise the path returned by the rootPath. See also home , currentPath , rootPath , and tempPath. Returns true if the directory's path is absolute; otherwise returns false. See isAbsolutePath. See also isRelative , makeAbsolute , and cleanPath. Returns true if path is absolute; returns false if it is relative.
See also count , entryList , and setFilter. Returns true if the directory is readable and we can open files by name; otherwise returns false. Warning: A false value from this function is not a guarantee that files in the directory are not accessible.
Returns true if the directory path is relative; otherwise returns false. Returns true if path is relative; returns false if it is absolute. See also isRelative , isAbsolutePath , and makeAbsolute. Returns true if the directory is the root directory; otherwise returns false. Note: If the directory is a symbolic link to the root directory this function returns false.
If you want to test for this use canonicalPath , e. Converts the directory path to an absolute path. If it is already absolute nothing happens. Returns true if the conversion succeeded; otherwise returns false. Returns true if the fileName matches the wildcard glob pattern filter ; otherwise returns false. The filter may contain multiple patterns separated by spaces or semicolons. The matching is case insensitive. Returns true if the fileName matches any of the wildcard glob patterns in the list of filters ; otherwise returns false.
Returns the path. This may contain symbolic links, but never contains redundant ". The returned path can be either absolute or relative see setPath. See also absoluteFilePath , filePath , and canonicalPath. Returns true if the file is removed successfully; otherwise returns false.
If a file or directory cannot be removed, removeRecursively keeps going and attempts to delete as many files and sub-directories as possible, then returns false.
If the directory was already removed, the method returns true expected result already reached. Note: this function is meant for removing a small application-internal directory such as a temporary directory , but not user-visible directories.
Returns true if there is at least one more entry in the directory; otherwise, false is returned. See also next , fileName , filePath , and fileInfo.
Advances the iterator to the next entry, and returns the file path of this new entry. If hasNext returns false , this function does nothing, and returns an empty QString. You can call fileName or filePath to get the current entry file name or path, or fileInfo to get a QFileInfo for the current entry.
See also hasNext , fileName , filePath , and fileInfo. Documentation contributions included herein are the copyrights of their respective owners. Qt and respective logos are trademarks of The Qt Company Ltd. All other trademarks are property of their respective owners. We have, however, put the Find and Quit buttons and a stretchable space in a separate QHBoxLayout first, to make the buttons appear in the Window widget's bottom right corner. Alternatively, we could have used Qt Designer to construct a UI file, and uic to generate this code.
We did not create a QMenuBar with a Quit menu item; but we would still like to have a keyboard shortcut for quitting. Since we construct a QShortcut with QKeySequence::Quit , and connect it to QApplication::quit , on most platforms it will be possible to press Control-Q to quit or whichever standard Quit key is configured on that platform.
On macOS, this is redundant, because every application gets a Quit menu item automatically; but it helps to make the application portable. The browse slot presents a file dialog to the user, using the QFileDialog class. QFileDialog enables a user to traverse the file system in order to select one or many files or a directory. The easiest way to create a QFileDialog is to use the convenience static functions. Here we use the static QFileDialog::getExistingDirectory function which returns an existing directory selected by the user.
Then we display the directory in the directory combobox using the QComboBox::addItem function and update the current index. QComboBox::addItem adds an item to the combobox with the given text if not already present in the list , and containing the specified userData. The item is appended to the list of existing items. The find slot is called whenever the user requests a new search by pressing the Find button.
First we eliminate any previous search results by setting the table widgets row count to zero. Then we retrieve the specified file name, text, and directory path from the respective comboboxes.
0コメント