本文整理汇总了C++中QDir::toNativeSeparators方法的典型用法代码示例。如果您正苦于以下问题:C++ QDir::toNativeSeparators方法的具体用法?C++ QDir::toNativeSeparators怎么用?C++ QDir::toNativeSeparators使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDir
的用法示例。
在下文中一共展示了QDir::toNativeSeparators方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertPath
QString Playlist::convertPath(QString filename){
QString filepath;
QUrl url(filename);
filepath = url.toLocalFile();
QDir file;
filepath = file.toNativeSeparators(filepath);
return filepath;
}
示例2: getFolder
QString MediaStorageDlg::getFolder()
{
QFileDialog dlg(this);
dlg.setFileMode(QFileDialog::DirectoryOnly);
if(!dlg.exec())
return QString();
QDir dir = dlg.directory();
return dir.toNativeSeparators(dir.absolutePath());
}
示例3: MoveImageToProject
// Move image to a project path "img"
// @input:
// - QString - unempty full image file path
// @output:
// - empty QString - can't move image
// - same QString - image is already in project folder
// - new unempty QString - copied image path
QString ImgFilesService::MoveImageToProject(const QString &t_imgPath)
{
if ( true == t_imgPath.isEmpty() )
{
qDebug() << "MoveImageToProject(): Error - invalid arguments";
QString empty;
return empty;
}
if ( false == CheckImgExist(t_imgPath) )
{
qDebug() << "MoveImageToProject(): Error - nothing to move";
QString empty;
return empty;
}
// Images have to be stored in directory PROJECT_IMG_PATH
QDir directory;
QString pathToImgDir = directory.currentPath();
pathToImgDir.append(PROJECT_IMG_PATH);
pathToImgDir = directory.toNativeSeparators(pathToImgDir);
directory.mkpath(pathToImgDir);
QString imgToMove;
imgToMove = directory.toNativeSeparators(t_imgPath);
// We should check if user choosed image from PROJECT_IMG_PATH
if ( true == imgToMove.startsWith(pathToImgDir) )
{
qDebug() << "File" << imgToMove << "is already in project";
return t_imgPath;
}
QFileInfo imgCopyInfo(imgToMove);
QString imgCopyPath;
for (int i = 0; imgCopyInfo.exists(); i++)
{
imgCopyInfo.setFile(imgToMove);
imgCopyPath = pathToImgDir + imgCopyInfo.baseName();
if ( 0 == i )
{
imgCopyPath += QString(".%1").arg(imgCopyInfo.completeSuffix());
}
else
{
imgCopyPath += QString("_%1.%2").arg(i).arg(imgCopyInfo.completeSuffix());
}
imgCopyInfo.setFile(imgCopyPath);
}
bool fileCopiedSuccessfully = QFile::copy(imgToMove, imgCopyPath);
if ( false == fileCopiedSuccessfully )
{
qDebug() << "MoveImgToProjectPath(): error - cant copy file" << imgToMove;
QString empty;
return empty;
}
return imgCopyPath;
}