当前位置: 首页>>代码示例>>C++>>正文


C++ QDir::absolutePath方法代码示例

本文整理汇总了C++中QDir::absolutePath方法的典型用法代码示例。如果您正苦于以下问题:C++ QDir::absolutePath方法的具体用法?C++ QDir::absolutePath怎么用?C++ QDir::absolutePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDir的用法示例。


在下文中一共展示了QDir::absolutePath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QGraphicsView

Robot25DWindow::Robot25DWindow(const QDir & imagesDir, QWidget *parent) :
    QGraphicsView(parent)
{
    setAttribute(Qt::WA_Hover);
    setMouseTracking(true);
    mousePressPosition_ = QPoint(-1, -1);
    setScene(new QGraphicsScene);
    const QString resPath = imagesDir.absolutePath();
    QImage bgImg = QImage(resPath+"/grass_0.png");
    QBrush bgBrush = QBrush(bgImg);
//    QBrush bgBrush = QBrush(QColor(Qt::black));
    setBackgroundBrush(bgBrush);
    setRenderHints(QPainter::Antialiasing|QPainter::TextAntialiasing);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_robotView = new Robot25D::RobotView(imagesDir, false, true, false, QSize(400,300));
    scene()->addItem(m_robotView);

    loadGame(resPath+"/default.pm.json");
//    m_robotView->setAnimated(true);    
    setWindowTitle(tr("Isometric Robot"));
}
开发者ID:woronin,项目名称:kumir2,代码行数:22,代码来源:robot25dwindow.cpp

示例2: gitRepositoryDefaultSignature

bool QGit::gitRepositoryDefaultSignature(const QDir &path, QString &name, QString &email)
{
    git_repository *repo = nullptr;
    git_signature *me = nullptr;
    int result = 0;
    bool ret = false;

    result = git_repository_open(&repo, path.absolutePath().toUtf8().constData());
    if (result)
    {
        goto cleanup;
    }

    result = git_signature_default(&me, repo);
    if (result)
    {
        goto cleanup;
    }

    name = me->name;
    email = me->email;

    ret = true;

cleanup:
    if (me)
    {
        git_signature_free(me);
        me = nullptr;
    }

    if (repo)
    {
        git_repository_free(repo);
        repo = nullptr;
    }

    return ret;
}
开发者ID:bokic,项目名称:gitmaster,代码行数:39,代码来源:qgit.cpp

示例3: cvSize

OpencvModule::OpencvModule(QDir filename,OniModule* pOniModule){

    bool success;
    Size = cvSize(RES_X,RES_Y);
    codec = CV_FOURCC('X', 'V', 'I', 'D');
    fThresCanny1 = 80;
    fThresCanny2 = fThresCanny1*3;

    outputFile=filename.absolutePath().toStdString();
    extension= ".avi";
    currentIndex=0;
    windowopened=false;

    success=setOutput(outputFile,codec,Size);
    float p[3];
    float t[3];

    //0 blue
    //1 green
    //2 red

    p[0]=1;
    p[1]=1;
    p[2]=1;
    t[0]=0.48888;
    t[1]=0.16666;
    t[2]=-0.166666;
    Pseudocolor=new psInfo(p,t);

    videostarttime.setHMS(0,0,0,0);
    NumFrames = 0;

    //In order to draw the skeleton;
    this->pOniModule = pOniModule;
    this->pSampleManager = pOniModule->GetSampleManager();
    this->pUserGenerator = pOniModule->GetUserGenerator();
    rgbdepth=Mat(480,640,CV_8UC3);

}
开发者ID:mlopezantequera,项目名称:CM-GUI,代码行数:39,代码来源:opencvmodule.cpp

示例4: exportErrors

void QgsGeometryCheckerResultTab::exportErrors()
{
  QString initialdir;
  QDir dir = QFileInfo( mChecker->featurePools().first()->layer()->dataProvider()->dataSourceUri() ).dir();
  if ( dir.exists() )
  {
    initialdir = dir.absolutePath();
  }

  QString selectedFilter;
  QString file = QFileDialog::getSaveFileName( this, tr( "Select Output File" ), initialdir, QgsVectorFileWriter::fileFilterString(), &selectedFilter );
  if ( file.isEmpty() )
  {
    return;
  }

  file = QgsFileUtils::addExtensionFromFilter( file, selectedFilter );
  if ( !exportErrorsDo( file ) )
  {
    QMessageBox::critical( this, tr( "Export Errors" ), tr( "Failed to export errors to %1." ).arg( QDir::toNativeSeparators( file ) ) );
  }
}
开发者ID:AlisterH,项目名称:Quantum-GIS,代码行数:22,代码来源:qgsgeometrycheckerresulttab.cpp

示例5: qCopyDirectory

/**
  qCopyDirectory -- 拷贝目录
  fromDir : 源目录
  toDir   : 目标目录
  bCoverIfFileExists : ture:同名时覆盖  false:同名时返回false,终止拷贝
  返回: ture拷贝成功 false:拷贝未完成
*/
bool qCopyDirectory(const QDir& fromDir, const QDir& toDir, bool bCoverIfFileExists)
{
    QDir formDir_ = fromDir;
    QDir toDir_ = toDir;

    if(!toDir_.exists())
    {
        if(!toDir_.mkdir(toDir.absolutePath()))
            return false;
    }

    QFileInfoList fileInfoList = formDir_.entryInfoList();
    foreach(QFileInfo fileInfo, fileInfoList)
    {
        if(fileInfo.fileName() == "." || fileInfo.fileName() == "..")
            continue;

        //拷贝子目录
        if(fileInfo.isDir())
        {
            //递归调用拷贝
            if(!qCopyDirectory(fileInfo.filePath(), toDir_.filePath(fileInfo.fileName())))
                return false;
        }
        //拷贝子文件
        else
        {
            if(bCoverIfFileExists && toDir_.exists(fileInfo.fileName()))
            {
                toDir_.remove(fileInfo.fileName());
            }
            if(!QFile::copy(fileInfo.filePath(), toDir_.filePath(fileInfo.fileName())))
            {
                return false;
            }
        }
    }
    return true;
}
开发者ID:LinLinYi,项目名称:kirogi,代码行数:46,代码来源:main.cpp

示例6: on_exePath_textChanged

void CaptureDialog::on_exePath_textChanged(const QString &text)
{
  QString exe = text;

  // This is likely due to someone pasting a full path copied using copy path. Removing the quotes
  // is safe in any case
  if(exe.startsWith(QLatin1Char('"')) && exe.endsWith(QLatin1Char('"')) && exe.count() > 2)
  {
    exe = exe.mid(1, exe.count() - 2);
    ui->exePath->setText(exe);
    return;
  }

  QFileInfo f(exe);
  QDir dir = f.dir();
  bool valid = dir.makeAbsolute();

  if(valid && f.isAbsolute())
  {
    QString path = dir.absolutePath();

    if(!m_Ctx.Replay().CurrentRemote())
      path = QDir::toNativeSeparators(path);

    // match the path separators from the path
    if(exe.count(QLatin1Char('/')) > exe.count(QLatin1Char('\\')))
      path = path.replace(QLatin1Char('\\'), QLatin1Char('/'));
    else
      path = path.replace(QLatin1Char('/'), QLatin1Char('\\'));

    ui->workDirPath->setPlaceholderText(path);
  }
  else if(exe.isEmpty())
  {
    ui->workDirPath->setPlaceholderText(QString());
  }

  UpdateGlobalHook();
}
开发者ID:etnlGD,项目名称:renderdoc,代码行数:39,代码来源:CaptureDialog.cpp

示例7: slot_saveAs

void PythonConsole::slot_saveAs()
{
	QString oldFname = filename;
	QString dirName  = QDir::homePath();
	if (!filename.isEmpty())
	{
		QFileInfo fInfo(filename);
		QDir fileDir = fInfo.absoluteDir();
		if (fileDir.exists())
			dirName = fileDir.absolutePath();
	}
	filename = QFileDialog::getSaveFileName(this,
			tr("Save the Python Commands in File"),
			dirName,
			tr("Python Scripts (*.py *.PY)"));
	if (filename.isEmpty())
	{
		filename = oldFname;
		return;
	}
	slot_save();
}
开发者ID:HOST-Oman,项目名称:scribus,代码行数:22,代码来源:pconsole.cpp

示例8: findFoldersAndFiles

void findFoldersAndFiles(QDir& findFolder, QStringList& fList)
{
	QString dirPath = findFolder.absolutePath();
	QStringList list = findFolder.entryList(QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden | QDir::Dirs, QDir::Name);
	for (int i = 0; i < list.size(); ++i)
	{
		QString fullString = dirPath + "/" + list.at(i);
		QFileInfo fileInfo(fullString);
		if ((fileInfo.fileName() != ".") && (fileInfo.fileName() != ".."))
		{
			if (fileInfo.isDir())
			{
				fList.push_back(fullString);
				findFolder.setPath(fullString);
				findFoldersAndFiles(findFolder, fList);
				findFolder.cdUp();
			}
			else
				fList.push_back(fullString);
		}
	}
}
开发者ID:FreeDegree,项目名称:Zhang,代码行数:22,代码来源:ViewerUtil.cpp

示例9: getImage

/**
 * Funtion returns image pointer to Image located 
 * in cache folder where shoul be downloaded cover 
 * with name from parameter.
 * @param name
 * @return 
 */
QImage* CoverDownloader::getImage(QString name) {
    QDir d = QDir::current();

    std::cout << "Current dir cover.. " << d.absolutePath().toStdString() << std::endl;
    if (d.cd("cache")) {
        QImage * img = new QImage();
        QStringList filters;
        filters << name + ".*";
        QStringList files = d.entryList(filters, QDir::Readable | QDir::Files | QDir::NoSymLinks);
        for (QStringList::Iterator it = files.begin(); it != files.end(); ++it) {
            std::cout << it->toStdString() << std::endl;
            if (img->load("cache/" + *it)) {
                break;
            }
        }
        if (!img->isNull()) {
            return img;
        }
        SAFE_DELETE(img);
    }
    return NULL;
}
开发者ID:helcl42,项目名称:Streaming,代码行数:29,代码来源:CoverDownloader.cpp

示例10: searchForAnt

void AndroidSettingsWidget::searchForAnt(const Utils::FileName &location)
{
    if (!m_androidConfig.antLocation().isEmpty())
            return;
    if (location.isEmpty())
        return;
    QDir parentFolder = location.toFileInfo().absoluteDir();
    foreach (const QString &file, parentFolder.entryList()) {
        if (file.startsWith(QLatin1String("apache-ant"))) {
            Utils::FileName ant = Utils::FileName::fromString(parentFolder.absolutePath());
            ant.appendPath(file).appendPath(QLatin1String("bin"));
            if (Utils::HostOsInfo::isWindowsHost())
                ant.appendPath(QLatin1String("ant.bat"));
            else
                ant.appendPath(QLatin1String("ant"));
            if (ant.toFileInfo().exists()) {
                m_androidConfig.setAntLocation(ant);
                m_ui->AntLocationLineEdit->setText(ant.toUserOutput());
            }
        }
    }
}
开发者ID:Herysutrisno,项目名称:qt-creator,代码行数:22,代码来源:androidsettingswidget.cpp

示例11: on_addButton_pressed

void FileListDialog::on_addButton_pressed()
{
    QSettings settings("UFZ", "OpenGeoSys-5");
    QFileDialog dlg(this);
    dlg.setDirectory(settings.value("lastOpenedOgsFileDirectory").toString());
    dlg.setFileMode(QFileDialog::ExistingFiles);
    dlg.setNameFilter(this->getFileTypeString(_input_file_type));

    if (dlg.exec())
    {
        QStringList const file_names = dlg.selectedFiles();

        if (file_names.empty())
            return;

        QStringList list = _allFiles.stringList();
        list.append(file_names);
        _allFiles.setStringList(list);
        QDir const dir = QDir(file_names[0]);
        settings.setValue("lastOpenedOgsFileDirectory", dir.absolutePath());
    }
}
开发者ID:TomFischer,项目名称:ogs,代码行数:22,代码来源:FileListDialog.cpp

示例12: addRunningApplication

static bool addRunningApplication(const QString &rootPath)
{
    QFile file(runningApplicationsFilePath());
    QDir dir = QFileInfo(file).dir();

    if (!dir.exists()) {
        dir.mkpath(".");
        // set permissions of the dir
        QFile(dir.absolutePath()).setPermissions(QFile::ReadUser | QFile::WriteUser | QFile::ExeUser);
    }

    if (!file.open(QIODevice::WriteOnly | QIODevice::Append)) {
        return false;
    }

    TF_FLOCK(file.handle(), LOCK_EX); // lock
    file.write(rootPath.toLatin1());
    file.write("\n");
    TF_FLOCK(file.handle(), LOCK_UN); // unlock
    file.close();
    return true;
}
开发者ID:gaoxiaojun,项目名称:treefrog-framework,代码行数:22,代码来源:main.cpp

示例13: runTests

int TestRegistry::runTests(QStringList args) {
    int result = 0;
    int xunitoutFlagIndex = args.indexOf("-xunitout");
    bool usingXUnitOut = (xunitoutFlagIndex >= 0 && args.length() > xunitoutFlagIndex + 1);
    QDir outDir;
    if(usingXUnitOut) {
        outDir = QDir(args.at(xunitoutFlagIndex + 1));
        QDir().mkpath(outDir.absolutePath());
        args.removeAt(xunitoutFlagIndex);
        args.removeAt(xunitoutFlagIndex);
    }

    foreach(QObject *test, tests_) {
        QStringList testArgs = args;
        if(usingXUnitOut) {
            testArgs << "-xunitxml";
            testArgs << "-o";
            QString outFile = QString("%1.xml").arg(outDir.absoluteFilePath(test->metaObject()->className()));
            testArgs << outFile;
        }
        result |= QTest::qExec(test, testArgs);
    }
开发者ID:burnto,项目名称:qttestutil,代码行数:22,代码来源:TestRegistry.cpp

示例14: on_workDirBrowse_clicked

void CaptureDialog::on_workDirBrowse_clicked()
{
  QString initDir = "";

  if(QDir(ui->workDirPath->text()).exists())
  {
    initDir = ui->workDirPath->text();
  }
  else
  {
    QDir dir = QFileInfo(ui->exePath->text()).dir();
    if(dir.exists())
      initDir = dir.absolutePath();
    else if(m_Ctx->Config.LastCapturePath != "")
      initDir = m_Ctx->Config.LastCapturePath;
  }

  // TODO Remote

  // if(m_Core.Renderer.Remote == null)
  {
    QString dir = RDDialog::getExistingDirectory(this, "Choose working directory", initDir);

    if(dir != "")
      ui->workDirPath->setText(dir);
  }
  /*
  else
  {
    VirtualOpenFileDialog remoteBrowser = new VirtualOpenFileDialog(m_Core.Renderer);
    remoteBrowser.Opened += new
  EventHandler<FileOpenedEventArgs>(this.virtualWorkDirBrowser_Opened);

    remoteBrowser.DirectoryBrowse = true;

    remoteBrowser.ShowDialog(this);
  }
  */
}
开发者ID:Nexuapex,项目名称:renderdoc,代码行数:39,代码来源:CaptureDialog.cpp

示例15: saveProject

bool MainWindow::saveProject( QString fileName )
{
	if ( fileName.isEmpty() )
		return false;

	try
	{
		QDir d = QFileInfo( fileName ).absoluteDir();
		QString projectDir = QDir::cleanPath( d.absolutePath() );

		QDomDocument doc;
		QDomProcessingInstruction xmlHeaderPI = doc.createProcessingInstruction( "xml", "version=\"1.0\" " );
		doc.appendChild( xmlHeaderPI );

		QDomElement root = doc.createElement( "project" );
		root.setAttribute( "version", 1 );
		doc.appendChild( root );

		project.save( root, projectDir );
		spriteView->save(root);
		graphicsView->save( root );

		QFile outFile( fileName );
		if ( !outFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
			throw std::runtime_error( "cant open project file" );

		QTextStream stream( &outFile );
		stream << doc.toString();

		clearUndoHistory();
	}
	catch ( ... )
	{
		return false;
	}

	return true;
}
开发者ID:vladimirgamalian,项目名称:composer,代码行数:38,代码来源:MainWindow.cpp


注:本文中的QDir::absolutePath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。