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


C++ QFile::errorString方法代码示例

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


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

示例1: LoadFile

    bool StreamMail::LoadFile(const QString file) {
        ////qFatal(" unable to read ... ");
        bool filled = false;
        if (clear()) {

            QFile *f = new QFile(file);

            if (f->exists()) {
                /////
                if (f->open(QIODevice::ReadOnly)) {
                    //// read line by line 
                    if (f->isReadable()) {
                        linenr = -1;
                        while (!f->atEnd()) {
                            linenr++;
                            QByteArray crk = f->read(76);
                            d->write(crk);
                        }
                        f->close();
                        d->write(QByteArray("\n--\n--\n--\n--"));
                    }
                } else {
                    qDebug() << "######## file errors:" << f->errorString() << "\n";
                }
            }
        }

        if (d->bytesAvailable() > 23) {
            filled = true;
        }
        d->seek(0);
        return filled;
    }
开发者ID:Eidolian,项目名称:qt-gmail-access,代码行数:33,代码来源:mail_handler.cpp

示例2: acceptImage

void ExtractImages::acceptImage(DomImage *image)
{
    QString format = image->elementData()->attributeFormat();
    QString extension = format.left(format.indexOf(QLatin1Char('.'))).toLower();
    QString fname = m_imagesDir.absoluteFilePath(image->attributeName() + QLatin1Char('.') + extension);

    *m_output << "        <file>images/" << image->attributeName() << QLatin1Char('.') + extension << "</file>\n";

    QFile f;
    f.setFileName(fname);
    const bool isXPM_GZ = format == QLatin1String("XPM.GZ");
    QIODevice::OpenMode openMode = QIODevice::WriteOnly;
    if (isXPM_GZ)
        openMode |= QIODevice::Text;
    if (!f.open(openMode)) {
        fprintf(stderr, "%s: Error: Could not create image file %s: %s",
                qPrintable(m_option.messagePrefix()),
                qPrintable(fname), qPrintable(f.errorString()));
        return;
    }

    if (isXPM_GZ) {
        QTextStream *imageOut = new QTextStream(&f);
        imageOut->setCodec(QTextCodec::codecForName("UTF-8"));

        CPP::WriteIconData::writeImage(*imageOut, QString(), m_option.limitXPM_LineLength, image);
        delete imageOut;
    } else {
        CPP::WriteIconData::writeImage(f, image);
    }

    f.close();
}
开发者ID:wpbest,项目名称:copperspice,代码行数:33,代码来源:cppextractimages.cpp

示例3: SaveBurstsDual

void SaveBurstsDual(const QVector<BurstDual> &burstVectorDual, const QString filename)
{
    QFile file;
    if(filename.isEmpty()) qFatal("SaveBursts: enter a valid filename");
    else file.setFileName(filename);
    if(burstVectorDual.size()==0) AlexEvalLog::warning("No dual bursts to save!");
    if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) AlexEvalLog::warning(file.errorString());
    QTextStream out(&file);
    out.setRealNumberPrecision(11);
    out <<"# ALEX dual bursts\n# "<<burstVectorDual.size()<<" bursts were analyzed.\n";

    out<<burstVectorDual.first().toStringHeader().c_str();
    for(int i=0;i<burstVectorDual.size();++i) {
        out<<burstVectorDual.at(i).toString("",", ").c_str()<<"\n";
    }
    AlexEvalLog::text(burstVectorDual.size()+"bursts written to file "+file.fileName());
    file.close();

    //    out <<"# start time in s\tburst duration in ms\tproximity ratio\tstoichiometry ratio\tnumber of photons\tn_Dem_Dex\tn_Aem_Dex\tn_Dem_Aex\tn_Aem_Aex\tduration Dem in ms\tduration Aem in ms\tPR_RAW\tS_RAW\ttype\n";

    //    for(int i=0;i<burstVectorDual.size();++i) {
    //        out <<burstVectorDual.at(i).startTime<<"\t"<<burstVectorDual.at(i).duration*1e3<<"\t"
    //           <<burstVectorDual.at(i).proximityRatio<<"\t"<<burstVectorDual.at(i).stoichiometryRatio<<"\t"<<burstVectorDual.at(i).numberOfPhotons<<"\t"
    //           <<burstVectorDual.at(i).n_Dem_Dex<<"\t"<<burstVectorDual.at(i).n_Aem_Dex<<"\t"<<burstVectorDual.at(i).n_Dem_Aex<<"\t"<<burstVectorDual.at(i).n_Aem_Aex<<"\t"<<burstVectorDual.at(i).durationDonor*1e3<<"\t"<<burstVectorDual.at(i).durationAcceptor*1e3<<"\t"<<burstVectorDual.at(i).proximityRatioRaw<<"\t"<<burstVectorDual.at(i).stoichiometryRatioRaw<<"\t"<<(int)burstVectorDual.at(i).type<<"\n";
    //    }

}
开发者ID:jkriege2,项目名称:QuickFit3,代码行数:27,代码来源:alexdata.cpp

示例4: on_buttonSaveFile_clicked

/*-------------------------------------------------------------------------------------------------
 * on_buttonSaveFile_clicked --
 *-----------------------------------------------------------------------------------------------*/
void SetupDialog::on_buttonSaveFile_clicked ()
{
    QByteArray ba = "Font=";
    ba += fontEdit->text ();
    ba += "\nConfig=";
    ba += configEdit->text ();
    ba += "\nBoot=";
    ba += bootEdit->text ();
    ba += '\n';

    QString fileName = QFileDialog::getSaveFileName(this, "setup save file name", "",
									    "setup (*.b4s)");
    if (!fileName.endsWith (".b4s"))
	fileName.append (".b4s");

    QFile file (fileName);;
    if (!file.open(QIODevice::WriteOnly)) {
	QMessageBox::warning(this, tr ("setup file"),
		tr ("Cannot create file %1:%2.")
		.arg(fileName)
		.arg(file.errorString()));
	return;
    }

    file.write (ba);
    file.close ();
}
开发者ID:decadeeng,项目名称:conscriptor,代码行数:30,代码来源:setup.cpp

示例5: file

	Document::Document (const QString& filename, QObject *plugin)
	: DocURL_ (QUrl::fromLocalFile (filename))
	, Plugin_ (plugin)
	{
		QFile file (filename);
		if (!file.open (QIODevice::ReadOnly))
		{
			qWarning () << Q_FUNC_INFO
					<< "unable to open file"
					<< file.fileName ()
					<< file.errorString ();
			return;
		}

		QDomDocument doc;
		if (!doc.setContent (file.readAll (), true))
		{
			qWarning () << Q_FUNC_INFO
					<< "malformed XML in"
					<< filename;
			return;
		}

		FB2Converter conv (this, doc);
		auto textDoc = conv.GetResult ();
		SetDocument (textDoc);
		Info_ = conv.GetDocumentInfo ();
		TOC_ = conv.GetTOC ();
	}
开发者ID:mirok0,项目名称:leechcraft,代码行数:29,代码来源:document.cpp

示例6: setup

void DomainContentBackupManager::setup() {
    for (auto& rule : _backupRules) {
        removeOldBackupVersions(rule);
    }

    auto backups = getAllBackups();
    for (auto& backup : backups) {
        QFile backupFile { backup.absolutePath };
        if (!backupFile.open(QIODevice::ReadOnly)) {
            qCritical() << "Could not open file:" << backup.absolutePath;
            qCritical() << "    ERROR:" << backupFile.errorString();
            continue;
        }

        QuaZip zip { &backupFile };
        if (!zip.open(QuaZip::mdUnzip)) {
            qCritical() << "Could not open backup archive:" << backup.absolutePath;
            qCritical() << "    ERROR:" << zip.getZipError();
            continue;
        }

        for (auto& handler : _backupHandlers) {
            handler->loadBackup(backup.id, zip);
        }

        zip.close();
    }

    for (auto& handler : _backupHandlers) {
        handler->loadingComplete();
    }
}
开发者ID:AndrewMeadows,项目名称:hifi,代码行数:32,代码来源:DomainContentBackupManager.cpp

示例7: chargerFichier

void AddressBook::chargerFichier() {
    QString nomFichier = QFileDialog::getOpenFileName(this,
                                                      tr ("Charger depuis un fichier"),
                                                      "",
                                                      tr ("Carnet d'adresse (*.abk);;Tous les fichiers (*)"));
    if (nomFichier.isEmpty())
        return;
    else {
        QFile fichier (nomFichier);
        if (!fichier.open(QIODevice::ReadOnly)) {
            QMessageBox::information(this,
                                     tr ("Erreur de chargement"),
                                     fichier.errorString());
            return;
        }
        QDataStream in (&fichier);
        in.setVersion(QDataStream::Qt_4_7);
        listeContacts.empty();
        in >> listeContacts;
        if (listeContacts.isEmpty()) {
            QMessageBox::information (this ,
                                      tr ("Pas de contacts"),
                                      tr ("Aucun contact à importer dans le fichier"));
        } else {
            QMap<QString , QString>::iterator i = listeContacts.begin();
            nomLineEdit->setText(i.key());
            adresseTextEdit->setText(i.value());
        }

    }
    updateInterface(NavigationMode);
}
开发者ID:sangfroid70,项目名称:carnet_adresse,代码行数:32,代码来源:addressbook.cpp

示例8: checkAndGenerateNecessaryFile

void MainWindow::checkAndGenerateNecessaryFile()
{
  QDir dir;
  QString path = dir.absolutePath();
  
  if(!dir.exists(path + "/data"))
    dir.mkdir(path + "/data");
  
  if(!dir.exists(path + "/data/.temp"))
    dir.mkdir(path + "/data/.temp");
  
  if(!dir.exists(path + "/data/.temp/VirtualFence"))
    dir.mkdir(path + "/data/.temp/VirtualFence");
  
  QFile file;
  path = path + "/data/.temp/VirtualFence/";
  if (!file.exists(path + "config.ini"))
  {
    QString fileName = path + "config.ini";
    QFile file2(fileName);
    if (!file2.open(QFile::WriteOnly | QFile::Text))
    {
      QMessageBox::warning(this, tr("Create ini file"),
                           tr("Cannot create ini file %1:\n%2.")
                           .arg(fileName)
                           .arg(file.errorString()));
      return;
    }
    
    //write the ini file content here
    QTextStream out(&file2);         
    helper::writeDefautlVirtualFecingIni(out);
    file2.close();     
  }
}
开发者ID:heroddaji,项目名称:rulebasedengine,代码行数:35,代码来源:MainWindow.cpp

示例9: on_importBtn_clicked

void AutomatedRssDownloader::on_importBtn_clicked()
{
    QString selectedFilter {m_formatFilterJSON};
    QString path = QFileDialog::getOpenFileName(
                this, tr("Import RSS rules"), QDir::homePath()
                , QString("%1;;%2").arg(m_formatFilterJSON, m_formatFilterLegacy), &selectedFilter);
    if (path.isEmpty() || !QFile::exists(path))
        return;

    QFile file {path};
    if (!file.open(QIODevice::ReadOnly)) {
        QMessageBox::critical(
                    this, tr("I/O Error")
                    , tr("Failed to open the file. Reason: %1").arg(file.errorString()));
        return;
    }

    const RSS::AutoDownloader::RulesFileFormat format {
        (selectedFilter == m_formatFilterJSON)
                ? RSS::AutoDownloader::RulesFileFormat::JSON
                : RSS::AutoDownloader::RulesFileFormat::Legacy
    };

    try {
        RSS::AutoDownloader::instance()->importRules(file.readAll(),format);
    }
    catch (const RSS::ParsingError &error) {
        QMessageBox::critical(
                    this, tr("Import Error")
                    , tr("Failed to import the selected rules file. Reason: %1").arg(error.message()));
    }
}
开发者ID:elFarto,项目名称:qBittorrent,代码行数:32,代码来源:automatedrssdownloader.cpp

示例10: stream

int QMacPasteboardMimeQt3Any::registerMimeType(const QString &mime)
{
    if(!mime_registry.contains(mime)) {
        if(!loadMimeRegistry()) {
            qWarning("QMacPasteboardMimeAnyQt3Mime: Internal error");
            return 0;
        }
        if(!mime_registry.contains(mime)) {
            if(!library_file.isOpen()) {
                if(!library_file.open(QIODevice::WriteOnly)) {
                    qWarning("QMacPasteboardMimeAnyQt3Mime: Failure to open %s -- %s", library_file.fileName().toLatin1().constData(),
                             library_file.errorString().toLatin1().constData());
                    return false;
                }
            }
            int ret = ++current_max;
            mime_registry_loaded = QFileInfo(library_file).lastModified();
            QTextStream stream(&library_file);
            stream << mime << endl;
            stream << ret << endl;
            mime_registry.insert(mime, ret);
            library_file.flush(); //flush and set mtime
            return ret;
        }
    }
    return mime_registry[mime];
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:27,代码来源:qmime_mac.cpp

示例11: handleAccepted

			void StartupFirstPage::handleAccepted ()
			{
				for (int i = 0; i < Ui_.Tree_->topLevelItemCount (); ++i)
				{
					QTreeWidgetItem *item = Ui_.Tree_->topLevelItem (i);
					if (item->checkState (0) != Qt::Checked)
						continue;

					QString set = item->data (0, RoleSet).toString ();
					QString filename = item->data (0, RoleFile).toString ();
					QString full = QString (":/resources/default/%1/%2")
						.arg (set)
						.arg (filename);
					QFile file (full);
					if (!file.open (QIODevice::ReadOnly))
					{
						qWarning () << Q_FUNC_INFO
							<< "could not open file for read only"
							<< full
							<< file.errorString ();
						continue;
					}

					QString contents = QTextCodec::codecForName ("UTF-8")->
						toUnicode (file.readAll ());
					Core::Instance ().HandleEntity (contents,
							static_cast<QLineEdit*> (Ui_.Tree_->itemWidget (item, 1))->text ());
				}
			}
开发者ID:Apkawa,项目名称:leechcraft,代码行数:29,代码来源:startupfirstpage.cpp

示例12: createProject

int createProject(const QString &outFileName)
{
    QDir currentDir = QDir::current();
    QString currentDirName = currentDir.dirName();
    if (currentDirName.isEmpty())
        currentDirName = QLatin1String("root");

    QFile file;
    bool isOk = false;
    if (outFileName.isEmpty()) {
        isOk = file.open(stdout, QFile::WriteOnly | QFile::Text);
    } else {
        file.setFileName(outFileName);
        isOk = file.open(QFile::WriteOnly | QFile::Text);
    }
    if (!isOk) {
        fprintf(stderr, "Unable to open %s: %s\n",
                outFileName.isEmpty() ? qPrintable(outFileName) : "standard output",
                qPrintable(file.errorString()));
        return 1;
    }

    QTextStream out(&file);
    out << QLatin1String("<!DOCTYPE RCC><RCC version=\"1.0\">\n"
                         "<qresource>\n");

    // use "." as dir to get relative file pathes
    dumpRecursive(QDir(QLatin1String(".")), out);

    out << QLatin1String("</qresource>\n"
                         "</RCC>\n");

    return 0;
}
开发者ID:KDE,项目名称:necessitas-installer-framework,代码行数:34,代码来源:rccmain.cpp

示例13: error

 /// Takes the error string from given file and emits an error indication.
 /// Closes the files and stops the copy. Always returns false
 bool error(QFile & f) {
     m_error = f.errorString();
     m_error.append(QStringLiteral("(in %1 file").arg(f.objectName()));
     emit finished(false, m_error);
     close();
     return false;
 }
开发者ID:KubaO,项目名称:stackoverflown,代码行数:9,代码来源:main.cpp

示例14: SaveBursts

int SaveBursts(const QVector<Burst> &burstVector, const BurstSearchParams_t BurstSearchParams, const QString filename)
{
    QFile file;
    if(filename.isEmpty()) qFatal("SaveBursts: enter a valid filename");
    else file.setFileName(filename);

    if(burstVector.size()==0) {
        AlexEvalLog::warning("vector is empty");
        return EXIT_FAILURE;
    }
    if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
        AlexEvalLog::warning(file.errorString());
        return EXIT_FAILURE;
    }
    QTextStream out(&file);
    out << BurstSearchParams.toString("# ","\t") //Burst Search with parameters\tM="<<BurstSearchParams.M<<"\tL="<<BurstSearchParams.L()<<" \tT="<<BurstSearchParams.T*1e6<<" us.\t"
       <<".\t" <<burstVector.size()<<" bursts were found.\n";
    out <<"# start photon \tstart time in s \tnumber of photons \tburst duration in ms\n";
    out.setRealNumberPrecision(11);
    for(int i=0;i<burstVector.size();++i) {
        out <<burstVector[i].startIdx<<"\t"<<burstVector[i].startTime<<"\t"
           <<burstVector[i].numberOfPhotons<<"\t"<<burstVector[i].duration*1e3<<"\n";
    }

    AlexEvalLog::text(burstVector.size() + "bursts written to file " + file.fileName());
    file.close();
    return EXIT_SUCCESS;

}
开发者ID:jkriege2,项目名称:QuickFit3,代码行数:29,代码来源:alexdata.cpp

示例15: hookItemLoad

	void Plugin::hookItemLoad (IHookProxy_ptr, Item *item)
	{
		if (!FetchedItems_.contains (item->ItemID_))
			return;

		const quint64 id = item->ItemID_;
		if (!ContentsCache_.contains (id))
		{
			QDir dir = StorageDir_;

			dir.cd (QString::number (id % 10));
			QFile file (dir.filePath (QString ("%1.html").arg (id)));
			if (!file.open (QIODevice::ReadOnly))
			{
				qWarning () << Q_FUNC_INFO
						<< "unable to open file:"
						<< file.fileName ()
						<< file.errorString ();
				return;
			}

			ContentsCache_ [id] = QString::fromUtf8 (file.readAll ());
		}

		const QString& contents = ContentsCache_ [id];
		if (!contents.isEmpty ())
			item->Description_ = contents;
	}
开发者ID:aboduo,项目名称:leechcraft,代码行数:28,代码来源:bodyfetch.cpp


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