本文整理汇总了C++中QDir::tempPath方法的典型用法代码示例。如果您正苦于以下问题:C++ QDir::tempPath方法的具体用法?C++ QDir::tempPath怎么用?C++ QDir::tempPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDir
的用法示例。
在下文中一共展示了QDir::tempPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fileShareContentChanged
void NfcSharing::fileShareContentChanged(QString paths) {
NfcShareFilesContent request;
QList<QUrl> urls;
QDir dir;
QStringList list = paths.split(",");
qDebug() << "XXXX Current Path" << dir.currentPath() << endl;
qDebug() << "XXXX Home Path" << dir.homePath() << endl;
qDebug() << "XXXX Temp Path" << dir.tempPath() << endl;
QString publicPath(dir.currentPath().append("/app/public/"));
for (int i = 0; i < list.size(); ++i) {
QUrl url(QString("file://").append(publicPath).append(list.at(i)));
urls.append(url);
QFileInfo fi(url.toLocalFile());
qDebug() << "XXXX To Local File" << url.toLocalFile() << endl;
qDebug() << "XXXX File String" << list.at(i) << endl;
qDebug() << "XXXX File URL" << url << endl;
qDebug() << "XXXX Absolute File Path" << fi.absoluteFilePath() << endl;
qDebug() << "XXXX Absolute Path" << fi.absolutePath() << endl;
}
request.setFileUrls(urls);
NfcShareSetContentError::Type rc = _nfcShareManager->setShareContent(request);
qDebug() << "XXXX File setShareContent rc=" << rc << endl;
}
示例2: sOpenDoc
void Documents::sOpenDoc(QString mode)
{
QString ui;
QString docType = _doc->currentItem()->rawValue("target_type").toString();
int targetid = _doc->currentItem()->id("target_number");
ParameterList params;
if (docType == "Q" && mode == "view")
params.append("mode", "viewQuote");
else if (docType == "Q" && mode == "edit")
params.append("mode", "editQuote");
else
params.append("mode", mode);
// TODO: image -- change to use docass instead of imageass
if (docType == "IMG")
{
XSqlQuery img;
img.prepare("SELECT imageass_image_id "
"FROM imageass "
"WHERE (imageass_id=:imageass_id); ");
img.bindValue(":imageass_id", _doc->id());
img.exec();
img.first();
if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Getting Image Info"),
img, __FILE__, __LINE__))
return;
params.append("image_id", img.value("imageass_image_id").toInt());
imageview newdlg(this, "", TRUE);
newdlg.set(params);
if (newdlg.exec() != QDialog::Rejected)
refresh();
return;
}
// TODO: url -- change to use docass instead of url
// TODO: separate URL from FILE handling and replace use of url view
else if (docType == "URL" || docType == "FILE")
{
if (mode == "edit")
{
ParameterList params;
params.append("url_id", targetid);
docAttach newdlg(this, "", TRUE);
newdlg.set(params);
newdlg.exec();
refresh();
return;
}
XSqlQuery qfile;
qfile.prepare("SELECT url_id, url_source_id, url_source, url_title, url_url, url_stream"
" FROM url"
" WHERE (url_id=:url_id);");
qfile.bindValue(":url_id", _doc->id());
qfile.exec();
// If file is in the database, copy to a temp. directory in the file system and open it.
if (qfile.first() && (docType == "FILE"))
{
QFileInfo fi( qfile.value("url_url").toString() );
QDir tdir;
// TODO: QDesktopServices::openUrl(urldb) on windows does not open files
// containing spaces. why not?
#ifdef Q_WS_WIN
QString fileName = fi.fileName().remove(" ");
#else
QString fileName = fi.fileName();
#endif
QString filePath = tdir.tempPath() + "/xtTempDoc/" +
qfile.value("url_id").toString() + "/";
QFile tfile(filePath + fileName);
// Remove any previous watches
if (_guiClientInterface)
_guiClientInterface->removeDocumentWatch(tfile.fileName());
if (! tdir.exists(filePath))
tdir.mkpath(filePath);
if (!tfile.open(QIODevice::WriteOnly))
{
QMessageBox::warning( this, tr("File Open Error"),
tr("Could Not Create File %1.").arg(tfile.fileName()) );
return;
}
tfile.write(qfile.value("url_stream").toByteArray());
QUrl urldb;
urldb.setUrl(tfile.fileName());
#ifndef Q_WS_WIN
urldb.setScheme("file");
#endif
tfile.close();
if (! QDesktopServices::openUrl(urldb))
{
QMessageBox::warning(this, tr("File Open Error"),
tr("Could not open %1.").arg(urldb.toString()));
//.........这里部分代码省略.........