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


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

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


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

示例1: testIODevice

void ut_load::testIODevice()
{
    QuillImageFilter *filter =
        QuillImageFilterFactory::createImageFilter("org.maemo.load");
    QFile *fileIO = new QFile("/usr/share/quillimagefilter-tests/images/16_color_palette.png");
    QVERIFY(fileIO->open(QIODevice::ReadOnly));
    QCOMPARE(fileIO->isOpen(),true);
    QCOMPARE(fileIO->isReadable(),true);
    QVERIFY(fileIO);
    filter->setIODevice(fileIO);
    QCOMPARE(fileIO, filter->iODevice());
    QImage image("/usr/share/quillimagefilter-tests/images/16_color_palette.png");
    QImage loadedImage1 = filter->apply(image);
    QVERIFY(Unittests::compareImage(loadedImage1, image));
    delete fileIO;
    delete filter;
}
开发者ID:matthewvogt,项目名称:quillimagefilters,代码行数:17,代码来源:ut_load.cpp

示例2: toFile

bool ccObject::toFile(QFile& out) const
{
    assert(out.isOpen() && (out.openMode() & QIODevice::WriteOnly));

    //class ID (dataVersion>=20)
    //DGM: on 64 bits since version 34
    uint64_t classID = static_cast<uint64_t>(getClassID());
    if (out.write((const char*)&classID,8) < 0)
        return WriteError();

    //unique ID (dataVersion>=20)
    //DGM: this ID will be usefull to recreate dynamic links between entities!
    uint32_t uniqueID = (uint32_t)m_uniqueID;
    if (out.write((const char*)&uniqueID,4) < 0)
        return WriteError();

    //name (dataVersion>=22)
    {
        QDataStream outStream(&out);
        outStream << m_name;
    }

    //flags (dataVersion>=20)
    uint32_t objFlags = (uint32_t)m_flags;
    if (out.write((const char*)&objFlags,4) < 0)
        return WriteError();

    //meta data (dataVersion>=30)
    {
        //count
        uint32_t metaDataCount = (uint32_t)m_metaData.size();
        if (out.write((const char*)&metaDataCount,4) < 0)
            return WriteError();

        //"key + value" pairs
        QDataStream outStream(&out);
        for (QVariantMap::const_iterator it = m_metaData.begin(); it != m_metaData.end(); ++it)
        {
            outStream << it.key();
            outStream << it.value();
        }
    }

    return true;
}
开发者ID:Windlkx,项目名称:trunk,代码行数:45,代码来源:ccObject.cpp

示例3: fromFile

bool ccObject::fromFile(QFile& in, short dataVersion)
{
	assert(in.isOpen() && (in.openMode() & QIODevice::ReadOnly));

	if (dataVersion<20)
		return CorruptError();

	//DGM: if we are here, we assume the class ID has already been read!
	//Call ccObject::readClassIDFromFile if necessary
	////class ID (dataVersion>=20)
	//uint32_t classID = 0;
	//if (in.read((char*)&classID,4)<0)
	//	return ReadError();

	//unique ID (dataVersion>=20)
	//DGM: this ID will be usefull to recreate dynamic links between entities!
	uint32_t uniqueID = 0;
	if (in.read((char*)&uniqueID,4)<0)
		return ReadError();
	m_uniqueID = (unsigned)uniqueID;

	//name
	if (dataVersion < 22) //old style
	{
		char name[256];
		if (in.read(name,256)<0)
			return ReadError();
		setName(name);
	}
	else //(dataVersion>=22)
	{
		QDataStream inStream(&in);
		inStream >> m_name;
	}

	//flags (dataVersion>=20)
	uint32_t flags = 0;
	if (in.read((char*)&flags,4)<0)
		return ReadError();
	m_flags = (unsigned)flags;

	return true;
}
开发者ID:dshean,项目名称:trunk,代码行数:43,代码来源:ccObject.cpp

示例4: out

void    installMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
#ifdef  CONSOLE
    static QFile        file(QDir::tempPath().append('/').append(APP_NAME).append("_svc.log"));
#else
    static QFile        file(QDir::tempPath().append('/').append(APP_NAME).append("_app.log"));
#endif
    static QTextStream  out(&file);

    if (!file.isOpen() && !file.open(QIODevice::WriteOnly | QIODevice::Text)) {
        abort();
    }

    out << QDateTime::currentDateTime().toString(QStringLiteral("[yy-MM-dd HH:mm:ss] "));
    switch (type) {
        case QtDebugMsg:
            out << "Debug: " << msg;
            break;
        case QtInfoMsg:
            out << "Info: " << msg;
            break;
        case QtWarningMsg:
            out << "Warning: " << msg;
            break;
        case QtCriticalMsg:
            out << "Critical: " << msg;
            break;
        case QtFatalMsg:
            out << "Fatal: " << msg;
            break;
    }

#ifdef  QT_DEBUG
    out << ' (' << context.file << ':' << context.line << ", " << context.function << ')';
#else
    Q_UNUSED(context);
#endif

    endl(out);
    if (type == QtFatalMsg) {
        abort();
    }
}
开发者ID:Max13,项目名称:Pulse-Qt,代码行数:43,代码来源:helpers.cpp

示例5: messageOutput

void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
    bool toFile = data.isOpen();

    QByteArray localMsg = msg.toLocal8Bit();
    QTextStream out;
    if (toFile)
        out.setDevice(&data);
    QString newLine = "\n";
    #ifdef Q_OS_WIN32
        newLine = "\r\n";
    #endif

    QString f = QString("%1").arg(context.function, -70, QChar(' '));

    switch (type) {
    case QtDebugMsg:
        if (toFile)
            out << "[" << f << "] " << localMsg << newLine;
        else
            fprintf(stderr, "%s %s%s", qPrintable(f), qPrintable(localMsg), qPrintable(newLine));
        break;
    case QtWarningMsg:
        if (toFile)
            out << "[" << f << "] " << "WARNING: " << localMsg << newLine;
        else
            fprintf(stderr, "%s WARNING: %s%s", qPrintable(f), qPrintable(localMsg), qPrintable(newLine));
        break;
    case QtCriticalMsg:
        if (toFile)
            out << "[" << f << "] " << "CRITICAL: " << localMsg << newLine;
        else
            fprintf(stderr, "%s CRITICAL: %s%s", qPrintable(f), qPrintable(localMsg), qPrintable(newLine));
        break;
    case QtFatalMsg:
        if (toFile)
            out << "[" << f << "] " << "FATAL: " << localMsg << newLine;
        else
            fprintf(stderr, "%s FATAL: %s%s", qPrintable(f), qPrintable(localMsg), qPrintable(newLine));
        abort();
    }
}
开发者ID:BlitzGLEP1326,项目名称:MediaElch,代码行数:42,代码来源:main.cpp

示例6: on_savefinButton_clicked

/**
 * Save the informations of coordinates
 * @brief MainWindow::on_savefinButton_clicked
 */
void MainWindow::on_savefinButton_clicked()
{
    myPlayer->Stop();
    ui->playBtn->setText("Play");
    //QMessageBox pour confirmer de sauvegarder
    QMessageBox msgBox;
    QFile infoFile;
    QTextStream output;
    QString listitem;
    msgBox.setInformativeText("Voulez-vous confirmer l'enregistrement?");
    msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Cancel);
    msgBox.setDefaultButton(QMessageBox::Save);
    int ret = msgBox.exec();
    if(ret == QMessageBox::Save){
        //myPlayer->setSaveFin(true);
        /****Créer une répertoire avec le nom de vidéo*************/
        QDir *temp = new QDir;
        QString repertoire = "C://temp/"+videoName;
        bool exist = temp->exists(repertoire);
        if(!exist)
        {
           bool ok = temp->mkdir(repertoire);
        }
        //Ouvrir la fenêtre de sauvegarder
        QString fileName = QFileDialog::getSaveFileName(this, "Sauvegarder trajectoire", repertoire,
                                                        "csv fichiers (*.csv);;All files (*.*)");
        infoFile.setFileName(fileName);
        infoFile.open(QIODevice::WriteOnly);
        /* Check it opened OK */
        if(!infoFile.isOpen()){
            qDebug() <<  "Error, unable to open" ;
        }
        output.setDevice(&infoFile);
        //Sauvegarder les textes dans QListWidget
        int c = ui->listWidget->count();
        for(int row = 0; row < c; row++){
            QListWidgetItem *item = ui->listWidget->item(row);
            listitem = item->text() + "\n";
            output<<listitem;
        }
    }
}
开发者ID:bigflower123,项目名称:PFE,代码行数:46,代码来源:mainwindow.cpp

示例7: WriteSavedRepos

void Gitarre::WriteSavedRepos ()
{
	QFile saveFile (UserDataDir.absolutePath() + "/repos");
	saveFile.open (QIODevice::WriteOnly | QIODevice::Text);
	if (saveFile.isOpen())
	{
		QXmlStreamWriter writer (&saveFile);
		writer.setAutoFormatting(true);
		writer.writeStartDocument("1.0");
		writer.writeStartElement ("saves");
		for (unsigned int i = 0; i < Repos.size(); ++i)
		{
			writer.writeStartElement ("repository");
			writer.writeAttribute ("path", Repos[i]->GetDir().absolutePath());
			writer.writeEndElement ();
		}
		writer.writeEndDocument();
		saveFile.close();
	}
}
开发者ID:poznyakovskiy,项目名称:gitarre,代码行数:20,代码来源:gitarre.cpp

示例8: ReadEntityHeader

//specific methods (old style)
static int ReadEntityHeader(QFile& in, unsigned &numberOfPoints, HeaderFlags& header)
{
	assert(in.isOpen());

	//number of points
	uint32_t ptsCount;
	if (in.read((char*)&ptsCount,4) < 0)
		return -1;
	numberOfPoints = (unsigned)ptsCount;

	//flags (colors, etc.)
	uint8_t flag;
	if (in.read((char*)&flag,1) < 0)
		return -1;

	header.flags.fromByte((unsigned char)flag);
	//assert(header.bit1 == true); //should always be 0!

	return 0;
}
开发者ID:FrankHXW,项目名称:trunk,代码行数:21,代码来源:BinFilter.cpp

示例9: settings

ExchangeFile::ExchangeFile()
{
    QFile exFile;
    exFile.setFileName("Message.txt");
    if(exFile.size() == 0){
        exFile.remove();
        return;
    }else{
        exFile.close();
    }
    QSettings settings("AO_Batrakov_Inc.", "EmployeeClient");
    QString fileName = settings.value("numprefix").toString();
    fileName += "_SRV.txt";

    qDebug()<<exFile.rename(fileName);
    exFile.close();

    qDebug()<<exFile.isOpen()<<" - "<<exFile.fileName()<<fileName;

    QString fN = exFile.fileName();

    PutFile putFile;
    putFile.putFile(fN);

    PutFile putFtp1;
    QString nullFileName = "Null.txt";
    //nullFileName += fN;
    QFile nullFile;
    nullFile.setFileName(nullFileName);
    nullFile.open(QIODevice::WriteOnly);
    QByteArray rr = "22\n10";
    nullFile.write(rr);
    nullFile.close();
    putFtp1.putFile(nullFileName);
    nullFile.remove();

    QFile file;

    file.setFileName("null.txt");
    file.remove();
}
开发者ID:AndrewBatrakov,项目名称:EmployeeClient,代码行数:41,代码来源:exchangefile.cpp

示例10: myMessageOutput

//----------------------------------------------------------------------------------------------------------------------
void myMessageOutput(QtMsgType /*type*/, const QMessageLogContext& /*context*/, const QString& msg)
{
#ifdef TEST_ONLY
    static QFile logFile("TokenTest_Log.txt");
#else
    static QFile logFile("TokenGraver_Log.txt");
#endif

    if (!logFile.isOpen()) {
        logFile.open(QIODevice::Append);
        QString newStartString("\r\n\r\n==========================================\r\n   Новый запуск   ");
        newStartString += curDateTime() + "\r\n==========================================\r\n\r\n";
        logFile.write(newStartString.toLocal8Bit());
    }

    if(!msg.isEmpty()) {
        QString logMsg = curTime() + "   " + msg + "\r\n";
        logFile.write(logMsg.toLocal8Bit());
        logFile.flush();
    }
}
开发者ID:toxa-svr,项目名称:TokenGraver,代码行数:22,代码来源:main.cpp

示例11: on_pbSaveLog_clicked

void MainWindow::on_pbSaveLog_clicked()
{
    use_settings;

    settings.beginGroup("FileDialogs");
    QString path = settings.value("BinDialogPath","").toString();
    settings.endGroup();


    QString s = QFileDialog::getSaveFileName(this, tr("Save log"),path,tr("Log (*.log);;All files (*.*)"));
    if(s.isEmpty())return;
    QFile f (s);
    f.open(QFile::WriteOnly);
    if(!f.isOpen())
    {
        QMessageBox::warning(this,tr("File save error"),tr("Can't save file"));
        return;
    }
    f.write(ui->consoleView->toPlainText().toUtf8());
    f.close();
}
开发者ID:f0ma,项目名称:hardwareexpert,代码行数:21,代码来源:mainwindow.cpp

示例12: generateReport

void CrashHandler::generateReport(void)
{
    Messagebox msgbox;
    QByteArray buf, comp_buf;
    QFile output;

    //Configures the path to the .crash file generated
    QString crash_file=QFileInfo((GlobalAttributes::TEMPORARY_DIR +
                                  GlobalAttributes::DIR_SEPARATOR +
                                  GlobalAttributes::CRASH_REPORT_FILE).arg(QDateTime::currentDateTime().toString("_yyyyMMdd_hhmm"))).absoluteFilePath();

    //Opens the file for writting
    output.setFileName(crash_file);
    output.open(QFile::WriteOnly);

    if(!output.isOpen())
        msgbox.show(trUtf8("Error"), Exception::getErrorMessage(ERR_FILE_NOT_WRITTEN).arg(crash_file), Messagebox::ERROR_ICON);
    else
    {
        buf.append(actions_txt->toPlainText().toUtf8());
        buf.append(CHR_DELIMITER);

        if(attach_mod_chk->isChecked())
            buf.append(model_txt->toPlainText().toUtf8());
        buf.append(CHR_DELIMITER);

        buf.append(stack_txt->toPlainText().toUtf8());
        buf.append(CHR_DELIMITER);

        //Compress the buffer (using zlib) in a compression rate at 8
        comp_buf=qCompress(buf, 8);

        //Saves the buffer
        output.write(comp_buf.data(), comp_buf.size());
        output.close();

        msgbox.show(trUtf8("Information"), trUtf8("Crash report successfuly generated! Please send the file <strong>%1</strong> to <em>%2</em> in order be debugged. Thank you for the collaboration!").arg(crash_file).arg("[email protected]"), Messagebox::INFO_ICON);
        this->close();
    }
}
开发者ID:jotawolf,项目名称:pgmodeler,代码行数:40,代码来源:crashhandler.cpp

示例13: fromFile_MeOnly

bool ccHObject::fromFile_MeOnly(QFile& in, short dataVersion)
{
	assert(in.isOpen() && (in.openMode() & QIODevice::ReadOnly));

	/*** ccHObject takes in charge the ccDrawableObject properties (which is not a ccSerializableObject) ***/

	//'visible' state (dataVersion>=20)
	if (in.read((char*)&visible,sizeof(bool))<0)
		return ReadError();
	//'lockedVisibility' state (dataVersion>=20)
	if (in.read((char*)&lockedVisibility,sizeof(bool))<0)
		return ReadError();
	//'colorsDisplayed' state (dataVersion>=20)
	if (in.read((char*)&colorsDisplayed,sizeof(bool))<0)
		return ReadError();
	//'normalsDisplayed' state (dataVersion>=20)
	if (in.read((char*)&normalsDisplayed,sizeof(bool))<0)
		return ReadError();
	//'sfDisplayed' state (dataVersion>=20)
	if (in.read((char*)&sfDisplayed,sizeof(bool))<0)
		return ReadError();
	//'colorIsOverriden' state (dataVersion>=20)
	if (in.read((char*)&colorIsOverriden,sizeof(bool))<0)
		return ReadError();
	if (colorIsOverriden)
	{
		//'tempColor' (dataVersion>=20)
		if (in.read((char*)tempColor,sizeof(colorType)*3)<0)
			return ReadError();
	}
	//'glTransEnabled' state (dataVersion>=20)
	if (in.read((char*)&glTransEnabled,sizeof(bool))<0)
		return ReadError();
	if (glTransEnabled)
		if (!glTrans.fromFile(in,dataVersion))
			return false;

	return true;
}
开发者ID:zhenglai,项目名称:trunk,代码行数:39,代码来源:ccHObject.cpp

示例14: loadDiffs

void MapsPrivate::loadDiffs( const QString& basepath, unsigned int id )
{
	// Try to read the index
	QFile mapdiflist( basepath + QString( "mapdifl%1.mul" ).arg( id ) );
	mapdifdata.setName( basepath + QString( "mapdif%1.mul" ).arg( id ) );
	mapdifdata.open( IO_ReadOnly );

	// Try to read a list of ids
	if ( mapdifdata.isOpen() && mapdiflist.open( IO_ReadOnly ) )
	{
		QDataStream listinput( &mapdiflist );
		listinput.setByteOrder( QDataStream::LittleEndian );
		unsigned int offset = 0;
		while ( !listinput.atEnd() )
		{
			unsigned int id;
			listinput >> id;
			mappatches.insert( id, offset );
			offset += sizeof( mapblock );
		}
		mapdiflist.close();
	}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:22,代码来源:maps.cpp

示例15: QByteArray

QByteArray QCOMM::md5(QFile &file)
{
    unsigned char *buf;
    bool isopen;
    if(!file.exists())
        return QByteArray();
    if(file.size()==0)
        return QByteArray();
    if(file.isOpen())
        isopen = TRUE;
    if(isopen&&(!file.open(QIODevice::ReadOnly)))
        return QByteArray();
    buf = file.map(0,file.size());
    if(isopen)
        file.close();
    if(0==buf)
        return QByteArray();
    QByteArray data = QByteArray::fromRawData((char*)buf,file.size());
    QByteArray md5 =  QCryptographicHash::hash (data, QCryptographicHash::Md5);
    file.unmap(buf);
    return md5;
}
开发者ID:httpftpli,项目名称:wm,代码行数:22,代码来源:qcomm.cpp


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