Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use Qt function name

Shulou Source: shulou.com Published: 2022-06-01 13:24:02 10月24日 Update

This article mainly introduces "how to use Qt function names". In daily operation, I believe many people have doubts about how to use Qt function names. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about how to use Qt function names. Next, please follow the editor to study!

Function name / / get saved file static QString getSaveName (const QString & filter, QString defaultDir = QCoreApplication::applicationDirPath ()); / / get selected file static QString getFileName (const QString & filter, QString defaultDir = QCoreApplication::applicationDirPath ()); / / non-blocking save file dialog static QString saveFileName (const QString & filter, const QString & defaultDir = "", const QString & fileName = "") / / get the selected file collection static QStringList getFileNames (const QString & filter, QString defaultDir = QCoreApplication::applicationDirPath ()); / / get the selected directory static QString getFolderName (); / / get the file name with the extension static QString getFileNameWithExtension (const QString & strFilePath); / / get the file static QStringList getFolderFileNames (const QStringList & filter) in the selected folder; / / whether static bool folderIsExist exists in the folder (const QString & strFolder) / / whether the file exists static bool fileIsExist (const QString & strFile); / / copy the file static bool copyFile (const QString & sourceFile, const QString & targetFile); / / Delete all files under the folder static void deleteDirectory (const QString & path); function body QString QUIHelper::getSaveName (const QString & filter, QString defaultDir) {return QFileDialog::getSaveFileName (0, "Select File", defaultDir, filter) } QString QUIHelper::getFileName (const QString & filter, QString defaultDir) {return QFileDialog::getOpenFileName (0, "Select File", defaultDir, filter);} QString QUIHelper::saveFileName (const QString & filter, const QString & defaultDir, const QString & fileName) {QString file; QFileDialog dialog; dialog.setFixedSize (900,600); dialog.setWindowModality (Qt::WindowModal); dialog.setWindowTitle ("Save File"); dialog.setLabelText (QFileDialog::Accept, "Save (& S)") Dialog.setLabelText (QFileDialog::Reject, & cancel (& C)); dialog.selectFile (fileName); dialog.setNameFilter (filter); dialog.setDirectory (defaultDir); if (dialog.exec () = = 1) {file = dialog.selectedFiles (). Value (0); file = QFileInfo (file). Suffix (). IsEmpty ()? ": file;} return file } QStringList QUIHelper::getFileNames (const QString & filter, QString defaultDir) {return QFileDialog::getOpenFileNames (0, "Select File", defaultDir, filter);} QString QUIHelper::getFolderName () {return QFileDialog::getExistingDirectory ();} QString QUIHelper::getFileNameWithExtension (const QString & strFilePath) {QFileInfo fileInfo (strFilePath); return fileInfo.fileName ();} QStringList QUIHelper::getFolderFileNames (const QStringList & filter) {QStringList fileList; QString strFolder = QFileDialog::getExistingDirectory () If (! strFolder.length () = = 0) {QDir myFolder (strFolder); if (myFolder.exists ()) {fileList = myFolder.entryList (filter);}} return fileList;} bool QUIHelper::folderIsExist (const QString & strFolder) {QDir tempFolder (strFolder); return tempFolder.exists ();} bool QUIHelper::fileIsExist (const QString & strFile) {QFile tempFile (strFile); return tempFile.exists () } bool QUIHelper::copyFile (const QString & sourceFile, const QString & targetFile) {bool ok; ok = QFile::copy (sourceFile, targetFile); / / cancel the copied file read-only attribute ok = QFile::setPermissions (targetFile, QFile::WriteOwner); return ok;} void QUIHelper::deleteDirectory (const QString & path) {QDir dir (path); if (! dir.exists ()) {return } dir.setFilter (QDir::AllEntries | QDir::NoDotAndDotDot); QFileInfoList fileList = dir.entryInfoList (); foreach (QFileInfo fi, fileList) {if (fi.isFile ()) {fi.dir (). Remove (fi.fileName ());} else {deleteDirectory (fi.absoluteFilePath ()); dir.rmdir (fi.absoluteFilePath ()) At this point, the study on "how to use Qt function names" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Files selections functions learning folders more help utility next dialogs properties file names articles methods theories directories knowledge articles websites materials Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MySQL Shulou Information Xiaomi Redmi