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


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

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


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

示例1: DefaultPathExistCheck

void MainWindow::DefaultPathExistCheck()
{
    QString path = "configure.conf";
    QFile* defaultPathFile = new QFile(path);

    if(defaultPathFile->exists())
    {
        if (defaultPathFile->open(QIODevice::ReadOnly | QIODevice::Text))
        {
            QTextStream in(defaultPathFile);
            while(!in.atEnd())
            {
                _defaultOutputPath = in.readLine();
                ui->_leDefaultDirPath->setText(_defaultOutputPath);
            }
        }
    }
    else
    {
        defaultPathFile->setFileName(path);
    }
    defaultPathFile->close();
}
开发者ID:aliyasoubi,项目名称:NNComputationReuseTool,代码行数:23,代码来源:mainwindow.cpp

示例2: loadChipdefs

void DefMgr::loadChipdefs()
{
    m_chipdefs.clear();

    static const QString defFileLocations[] =
    {
        ":/definitions/chipdefs",
        "./shupito_chipdefs.txt",
        Utils::storageLocation(Utils::DataLocation) + "/shupito_chipdefs.txt",
    };

    QFile file;
    for(quint8 i = 0; i < sizeof(defFileLocations)/sizeof(QString); ++i)
    {
        file.setFileName(defFileLocations[i]);
        if(!file.open(QIODevice::ReadOnly))
            continue;

        QTextStream stream(&file);
        parseChipdefs(stream);
        file.close();
    }
}
开发者ID:Tasssadar,项目名称:Lorris,代码行数:23,代码来源:defmgr.cpp

示例3: getProcessId

int KIPC::getProcessId(const QString &kludgetId)
{
    int pid = 0;
    QString pidfile = getPIDFile(kludgetId);
    if (QFile::exists(pidfile))
    {
        QFile file;
        file.setFileName(pidfile);
        if (file.open(QIODevice::ReadOnly))
        {
            QString text = file.readAll();
            file.close();
            pid = text.toInt();
        }
    }

    // qDebug(">>%s %d", qPrintable(kludgetId), pid);

    if (!checkProcess(pid))
        return 0;

    return pid;
}
开发者ID:Delgerdalai14,项目名称:kludgets,代码行数:23,代码来源:kipc.cpp

示例4: languages

QStringList Backend::languages()
{
    QStringList _languages;
    QString code, desc, line;

    QFile mFile;
    mFile.setFileName("/usr/local/share/pc-sysinstall/conf/avail-langs");
    if ( ! mFile.open(QIODevice::ReadOnly | QIODevice::Text))
       return QStringList();

    // Read in the meta-file for categories
    QTextStream in(&mFile);
    in.setCodec("UTF-8");
    while ( !in.atEnd() ) {
       line = in.readLine();
       code = line;
       code.truncate(line.indexOf(" "));
       desc = line.remove(0, line.indexOf(" "));
        _languages.append(desc.simplified() + " - (" + code.simplified() + ")");
    }
    mFile.close();
    return _languages;
}
开发者ID:KdeOs,项目名称:pcbsd,代码行数:23,代码来源:backend.cpp

示例5: readStudentDbFromFile

bool TestManager::readStudentDbFromFile()
{
	QFile file;
	quint32 magic;
	quint16 streamVersion;
	StudentDb newStudentDb(this);
	
	file.setFileName(testsDir + "/" + studentDbFileName);
	if(!file.exists())
	{
		qDebug() << "ERROR: File " << (testsDir + "/" + studentDbFileName) << " no exist.";
		return false;
	}
	if(!file.open(QIODevice::ReadOnly))
	{
		qDebug() << "ERROR: Cannot open file for reading: " << file.errorString();
		return false;
	}
	
	QDataStream in(&file);
	in >> magic >> streamVersion;
	
	if(magic != magicNumber)
	{
		qDebug() << "ERROR: File is not recognized by this application";
		return false;
	}
	else if(streamVersion > in.version())
	{
		qDebug() << "ERROR: File is from a more recent version of the application";
		return false;
	}
	
	in >> newStudentDb;
	*students = newStudentDb;
	return true;
}
开发者ID:Horsmir,项目名称:hstest,代码行数:37,代码来源:testmanager.cpp

示例6: addObject

/*!
 * \brief JsonParser::addObject
 * Dodaje obiekt do pliku json
 * \param type typ obiektu
 * \param speed prędkość obiektu
 * \param model model tabeli ze wskazanymi punktami
 */
void JsonParser::addObject(QString type, double speed, QStandardItemModel *model)
{
    QJsonValue type_ = type;
    QJsonObject object;
    object.insert("TypeObject", type_);

    object.insert("Speed", speed);

    QJsonArray array;
    QJsonObject point;
    QJsonValue value;

    for (int i = 0; i <model->rowCount(); i++) {
        value = model->takeItem(i,0)->data(Qt::DisplayRole).toDouble();
        point.insert("CoordX", value);
        value = model->takeItem(i,1)->data(Qt::DisplayRole).toDouble();
        point.insert("CoordY", value);
        array.insert(i,point);
    }
    value = array;
    object.insert("Points", value);
    objects.push_back(object);

    QJsonDocument d;
    QJsonObject obj;
    obj.insert("Objects", static_cast<QJsonValue>(objects));
    d.setObject(obj);
    d.toJson();


    QFile file;
    file.setFileName(fileName);
    file.open(QIODevice::WriteOnly | QIODevice::Text);

    file.write(d.toJson());
    file.close();
}
开发者ID:zprts,项目名称:simulator,代码行数:44,代码来源:jsonparser.cpp

示例7: loadJsonObject

int TestMonitor::loadJsonObject(QString &fileName,QJsonObject &jsonObj )
{
    pthread_mutex_lock(&conn_mutex);
    QFile file;

    QString sampleDir = "../../doc/json_sample/";
    sampleDir = "d:\\phonelin\\doc\\json_sample\\";
#if __linux__
    sampleDir = "/home/hamigua/phonelin/doc/json_sample/";
#endif

    file.setFileName(sampleDir + fileName);
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        DEBUG_INFO << "Failed to open json sameple file:" + sampleDir + fileName;
        pthread_mutex_unlock(&conn_mutex);
        return PL_RET_FAIL;
    }

    QString data = file.readAll();
    file.close();

    QJsonDocument sd = QJsonDocument::fromJson(data.toUtf8());
    if (!sd.isObject() || sd.isNull() || sd.isEmpty())
    {
        DEBUG_INFO << "Failed to open json sameple file:" + fileName;
        pthread_mutex_unlock(&conn_mutex);
        return PL_RET_FAIL;
    }

    jsonObj = sd.object();

    pthread_mutex_unlock(&conn_mutex);

    return PL_RET_OK;

}
开发者ID:HamiguaLu,项目名称:phonelin,代码行数:37,代码来源:testMonitor.cpp

示例8: on_actionLoad_cost_grid_triggered

void TsunamiEvacModel::on_actionLoad_cost_grid_triggered()
{
    QString fileName;
    fileName = QFileDialog::getOpenFileName(this,
        tr("Open Image"), QDir::homePath(), tr("Image Files (*.csv)"));
    QList<QStringList> myMat;

    QFile file;
    file.setFileName(fileName);
    if(file.open(QIODevice::ReadOnly))
        setStatus("File opened");
    else
        setStatus("Could not open file");

    while (!file.atEnd()){
        QByteArray line = file.readLine();
        QStringList temp;
        for(int i = 0; i < line.split(',').size(); i++)
            temp.append(line.split(',').at(i));
        myMat.append(temp);
    }

    QString temp;
    delete myGrid;
    myGrid = new Grid(myMat.size(),myMat.at(1).size(),this);

    for(int i = 0; i < myMat.size(); i++){
        for(int j = 0; j < myMat.at(i).size(); j++){

            myGrid->setValue(i,j,myMat.at(i).at(j).toInt());
            temp.append(myMat.at(i).at(j));
            temp.append(" ");
        }
        temp.append("\n");
    }
    ui->textBrowser->append(temp);
}
开发者ID:jef023,项目名称:evacmodel,代码行数:37,代码来源:tsunamievacmodel.cpp

示例9: Abrir

//metodos del menu archivo
void MainWindow::Abrir(){

    //QString nombreArchivo;
    nombreArchivo_ = QFileDialog::getOpenFileName(this,
                                                 tr("Abrir archivo de video"),
                                                 "",
                                                 tr("Archivo de video (*.mpeg *.avi *.wmv *.mp4 *.mov *.flv *.mp3 *.mpg)")
                                                 );
    if (nombreArchivo_ != "") {
        //Intentamos abrir el archivo
        QFile archivo;
        archivo.setFileName(nombreArchivo_);
        if (archivo.open(QFile::ReadOnly)) {

            mediaPlayer_->setMedia(QUrl::fromLocalFile(nombreArchivo_));

            mediaPlayer_->play();
            //mediaPlayer_->setVideoOutput(videoWidget_);


            playlist_->addMedia(QUrl::fromLocalFile(nombreArchivo_));


            archivo.close();

            Recientes_crear(nombreArchivo_);

        }



    }




}
开发者ID:Rabug,项目名称:curso-qt-osl-reproductor,代码行数:38,代码来源:mainwindow.cpp

示例10: open

bool FileManager::open( QString path, QList<TrackModel*>* const trackModels, CategoryData* const categoryData, ImageData* const imageData )
{
    trackModels->clear();

    QString jsonFromFile;
    QFile file;
    file.setFileName( path );
    file.open( QIODevice::ReadOnly | QIODevice::Text );
    jsonFromFile = file.readAll();
    file.close();

    // Get jsonObject out of jsonDoc
    QJsonDocument jsonDoc    = QJsonDocument::fromJson( jsonFromFile.toUtf8() );
    QJsonObject   jsonObject = jsonDoc.object();

    // Parse track data
    QJsonArray tracksArray = jsonObject.value("tracks").toArray();
    for ( int i = 0; i < tracksArray.size(); i++ )
    {
        QJsonObject trackObj    = tracksArray.at(i).toObject();
        TrackModel* trackModel  = new TrackModel( trackObj );
        trackModels->append( trackModel );
    }

    // Parse category data
    if ( jsonObject.contains("categoryPath") )
    {
        QString categoryPath = jsonObject.value("categoryPath").toString("");
        FileManager::import( categoryPath, categoryData, imageData );
        qDebug() << "Loaded category data from" << categoryPath;
    }
    else
        qDebug() << "No category data found...";

    return trackModels->size() > 0;
}
开发者ID:jcelerier,项目名称:Prism,代码行数:36,代码来源:FileManager.cpp

示例11: okToUpdate

bool NokiaScreen::okToUpdate()
{
    QString path = "/sys/devices/platform/omapfb/panel/backlight_level";
    QString strvalue;
    int value;

    QFile brightness;
    if (QFileInfo(path).exists() ) {
        brightness.setFileName(path);
    }

    if( !brightness.open(QIODevice::ReadOnly | QIODevice::Text)) {
        qWarning()<<"brightness File not opened";
    } else {
        QTextStream in(&brightness);
        in >> strvalue;
        brightness.close();
    }

    if (strvalue.toInt() > 1 )
        return true;
    else
        return false;
}
开发者ID:GodFox,项目名称:qtopia-ezx,代码行数:24,代码来源:nokiascreen.cpp

示例12: createStoragePool

QStringList StoragePoolControlThread::createStoragePool()
{
    QStringList result;
    QString path = args.first();
    QByteArray xmlData;
    QFile f;
    f.setFileName(path);
    if ( !f.open(QIODevice::ReadOnly) ) {
        emit errorMsg( QString("File \"%1\"\nnot opened.").arg(path) );
        return result;
    };
    xmlData = f.readAll();
    f.close();
    // flags: extra flags; not used yet, so callers should always pass 0
    unsigned int flags = 0;
    virStoragePoolPtr storagePool = virStoragePoolCreateXML(currWorkConnect, xmlData.data(), flags);
    if ( storagePool==NULL ) {
        sendConnErrors();
        return result;
    };
    result.append(QString("'<b>%1</b>' StoragePool from\n\"%2\"\nis created.").arg(virStoragePoolGetName(storagePool)).arg(path));
    virStoragePoolFree(storagePool);
    return result;
}
开发者ID:benklop,项目名称:qt-virt-manager,代码行数:24,代码来源:storage_pool_control_thread.cpp

示例13: next

PgnGame PgnGameIterator::next(bool* ok, int depth)
{
	Q_ASSERT(hasNext());

	int newDbIndex = m_dlg->databaseIndexFromGame(m_gameIndex);
	Q_ASSERT(newDbIndex != -1);

	if (newDbIndex != m_dbIndex)
	{
		m_dbIndex = newDbIndex;
		m_file.close();

		const PgnDatabase* db = m_dlg->m_dbManager->databases().at(m_dbIndex);
		if (db->status() == PgnDatabase::Ok)
		{
			m_file.setFileName(db->fileName());
			if (m_file.open(QIODevice::ReadOnly | QIODevice::Text))
				m_in.setDevice(&m_file);
			else
				m_in.setDevice(nullptr);
		}
	}

	PgnGame game;
	if (!m_file.isOpen())
	{
		*ok = false;
		m_gameIndex++;
		return game;
	}

	const PgnGameEntry* entry = m_dlg->m_pgnGameEntryModel->entryAt(m_gameIndex++);
	*ok = m_in.seek(entry->pos(), entry->lineNumber()) && game.read(m_in, depth);

	return game;
}
开发者ID:joergoster,项目名称:cutechess,代码行数:36,代码来源:gamedatabasedlg.cpp

示例14: open

bool codeEditor::open(QString name)
{
    QFile file;
    QFileInfo fileInfo;
    file.setFileName(name);
    fileInfo.setFile(file);

    if(file.open(QIODevice::ReadWrite|QIODevice::Text))
    {
        if(!read(&file))
            return false;

        file_path=name;

        name=fileInfo.suffix();
        if(name=="cpp"||name=="c")
            setLexer(new QsciLexerCPP);
        else if(name=="pas")
            setLexer(new QsciLexerPascal);
        return true;
    }

    return false;
}
开发者ID:AG3,项目名称:Lucky_OIer,代码行数:24,代码来源:codeeditor.cpp

示例15: saveShowData

void MainWindow::saveShowData()
{
    QString path="./";
    QString fileName=QFileDialog::getSaveFileName(this,
                     tr("Save Files(*.txt)"),
                     path,
                     tr("txt files(*.txt)"));
    if(fileName.isNull())
    {
        QMessageBox::warning(this,tr("File Name Error!"),tr("file name cann't be null!"),QMessageBox::Ok);
    }
    else
    {
        QFile saveFile;
        saveFile.setFileName(fileName);
        if(saveFile.open(QIODevice::ReadWrite|QFile::Text))
        {
            QTextStream saveFileStream(&saveFile);
            saveFileStream<<ui->reciveData->toPlainText();
            saveFileStream.atEnd();
            saveFile.close();
        }
    }
}
开发者ID:Randcc,项目名称:SerialPortQT,代码行数:24,代码来源:mainwindow.cpp


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