QT版本: 5.12.6 头文件: #include <QStandardPaths> 示例代码: qDebug()<<"系统字体目录路径:"<<QStandardPaths::standardLocations (QStandardPaths::FontsLocation); qDebug()<<"系统桌面目录路径:"<<QStandardPaths::standardLocations(QStandardPaths ()<<"用户图片目录路径:"<<QStandardPaths::standardLocations(QStandardPaths::PicturesLocation); qDebug()<<" 系统临时文件目录路径:"<<QStandardPaths::standardLocations(QStandardPaths::TempLocation); qDebug()<<"系统缓存目录路径 :"<<QStandardPaths::standardLocations(QStandardPaths::CacheLocation); qDebug()<<"系统下载目录路径:"<<QStandardPaths
03 QStandardPaths 是 Qt 框架中用于获取系统标准路径的类,它可以帮助你访问常见的系统目录(如文档、下载、配置等),跨平台兼容(Windows、Linux、macOS、Android/ ::StandardLocation>(); for(int i=0; i < m.keyCount(); ++i) { QStandardPaths::StandardLocation location = QStandardPaths::StandardLocation(m.value(i)); // 返回给定位置类型的本地化显示名称,如果找不到相关位置,则返回空QString paths << QPair<QString, QString>(m.valueToKey(m.value(i)), QStandardPaths::displayName(location)); paths << QPair<QString, QString>(m.valueToKey(m.value(i)), QStandardPaths::writableLocation(location)
4.写代码 #include <QApplication> #include "widget.h" #include <QtGui> #include <QAxObject> #include <QStandardPaths = 9 }; QString saveas() { QString file; QString filter; //如果版本低于QT5,则需要将: // QStandardPaths ::writableLocation(QStandardPaths::DesktopLocation), //改为:QDesktopServices::storageLocation(QDesktopServices ( NULL, //父组件 "另存为", //标题 QStandardPaths ::writableLocation(QStandardPaths::DesktopLocation), //设置路径, .表示当前路径,.
::writableLocation 获取系统中常用路径 lastPath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation QStandardPaths::writableLocation() 用于获取操作系统中特定类型的文件夹,例如图片、文档等。在这里当用户第一次打开程序时,程序会自动使用系统的图片目录作为初始路径。 ").toString(); // 如果没有上次记录的路径,使用系统默认的图片目录 if (lastPath.isEmpty()) { lastPath = QStandardPaths ::writableLocation(QStandardPaths::PicturesLocation); } // 打开文件选择对话框,初始路径设置为 lastPath QString ::writableLocation(QStandardPaths::PicturesLocation); } // 打开文件选择对话框,初始路径设置为 lastPath QString
include <QFile> #include <QFileDialog> #include <QTableWidget> #include <QTableWidgetItem> #include <QStandardPaths QPushButton::clicked, [=]() { QStringList filePaths = QFileDialog::getOpenFileNames(this, "选择图片", QStandardPaths ::writableLocation(QStandardPaths::PicturesLocation), "JPEG Images (*.jpg)"); for (const QString void MainWindow::saveTableToCSV() { QString filePath = QFileDialog::getSaveFileName(this, "保存表格", QStandardPaths ::writableLocation(QStandardPaths::DocumentsLocation), "CSV Files (*.csv)"); if (!
(this); nam->setStrictTransportSecurityEnabled(true); nam->enableStrictTransportSecurityStore(true, QStandardPaths ::writableLocation(QStandardPaths::CacheLocation) + QLatin1String("/hsts/")); SSL错误处理 QNetworkReply * QNetworkAccessManager(this); auto diskCache = new QNetworkDiskCache(nam); diskCache->setCacheDirectory(QStandardPaths ::writableLocation(QStandardPaths::CacheLocation) + QLatin1String("/http/")); nam->setCache(diskCache
sudo netease-cloud-music QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to ‘/tmp/runtime-root’ 05 sudo netease-cloud-music QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to ‘/tmp/runtime-root’ 05 Error ] [ 0] Player opening 已杀死 方法三: sudo pkill -9 netease-cloud 这个是方法二的延伸版本 sudo netease-cloud-music QStandardPaths
错误1 QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/var/volatile/tmp/runtime-root' Setting framebuffer screen HDMI1 (Invalid argument) Could not queue DRM page flip on screen HDMI1 (Invalid argument) 错误2 QStandardPaths
member of 'QDesktopServices' error : 'DataLocation' is not a member of 'QDesktopServices' 使用QStandardPaths storageLocation ( QDesktopServices ::DataLocation ) ). toString ( ) ; 为 QString path = s. value ( "db.path" ,QStandardPaths :: standardLocations (QStandardPaths ::DataLocation ) ). toString ( ) ; QtMutimedia替换了Phonon 音频、
以前使用QDesktopServices::storageLocation(QDesktopServices::xxxx)来获取一些系统目录,现在则要改成 QStandardPaths::writableLocation (QStandardPaths::xxxx) 7.
)return; //获取保存的文件路径 QString filepath = QFileDialog::getSaveFileName(this, "选择保存文件名称", QStandardPaths ::writableLocation(QStandardPaths::DocumentsLocation), "Excel 文件(*.xls *.xlsx
/textures QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/var/volatile/tmp/runtime-root' Setting /textures QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/var/volatile/tmp/runtime-root' Setting /textures QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/var/volatile/tmp/runtime-root' Setting /textures QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/var/volatile/tmp/runtime-root' Setting /textures QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/var/volatile/tmp/runtime-root' Setting
self.ui.textEdit.setText(self.cb.text()) def buttClicked(self): try: curPath = QStandardPaths.writableLocation (QStandardPaths.DocumentsLocation) # 默认保存在 ~/Documents pdf_name = "/paper.pdf" # 默认文件名为 paper.pdf •踩过的坑:在 Qt 中, 当我们需要不调用 QFileDialog 保存文件时,得用 QStandardPaths 指定路径,否则打包出来的软件没法保存。
//父组件 "另存为", //标题 QString("%1/%2").arg(QStandardPaths ::writableLocation(QStandardPaths::DesktopLocation)).arg(""+fileName+".pdf"),
fileDialog.setMimeTypeFilters(supportedMimeTypes); // 设置MIME类型过滤 // 设置默认打开目录为视频目录或用户主目录 fileDialog.setDirectory(QStandardPaths ::standardLocations(QStandardPaths::MoviesLocation).value(0, QDir::homePath())); if (fileDialog.exec
28.571306 [-] Xvfb is started: ['Xvfb', ':1599197258', '-screen', '0', '1024x768x24', '-nolisten', 'tcp'] QStandardPaths
LogSend(QString)),this,SLOT(Image_Log_Display(QString))); //获取系统图片目录的路径 QStringList dir_list=QStandardPaths ::standardLocations(QStandardPaths::PicturesLocation); if(dir_list.size()>0) { ui->lineEdit
QStandardPaths QStandardPaths 是 Qt4 的 QDesktopServices 的增强版,其 API 大部分基于 KDE4 的 KStandardDirs 。
备注:若打印警告信息"QStandardPaths: runtime directory…",忽略该信息即可,不影响程序运行。 Target# ./image_display .
it/s]QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root' failed to get the current