本文整理汇总了C++中QTextStream::unsetDevice方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextStream::unsetDevice方法的具体用法?C++ QTextStream::unsetDevice怎么用?C++ QTextStream::unsetDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextStream
的用法示例。
在下文中一共展示了QTextStream::unsetDevice方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveOutput
/*
* Saves the selected messages into a file, all if none selected
*/
void Superconductor_Messages::saveOutput()
{
QString s = QFileDialog::getSaveFileName(
"/home",
"Log files (*.log)",
this,
"save file dialog"
"Choose a filename to save under" );
if ( s ) {
QFile aFile( s );
QTextStream stream;
QString output;
if ( strings ) {
output = strings->join( "\n" );
output += "\n";
}
else {
output = " ";
}
if ( aFile.exists() ) {
switch( QMessageBox::warning( this, "Log Save",
"This file already exists. Overwrite?\n",
"Yes",
"No", 0, 0, 1 ) ) {
case 0: // user clicked ok... overwrite file
aFile.open( IO_WriteOnly | IO_Truncate | IO_Raw );
aFile.at( 0 );
stream.setDevice( &aFile );
stream << output;
stream.unsetDevice();
aFile.close();
this->close();
break;
case 1: // The user clicked the Quit or pressed Escape
break;
default:
break;
}
}
else { // file doesn't exist, just write it
if ( !s.endsWith( (QString)".log" )) {
s.append( ".log" );
aFile.setName( s );
}
aFile.open( IO_WriteOnly | IO_Truncate | IO_Raw );
aFile.at( 0 );
stream.setDevice( &aFile );
stream << output;
stream.unsetDevice();
aFile.close();
this->close();
}
}
}
示例2: finishStreams
bool ClassGenerator::finishStreams(const QString& baseName,
QTextStream& headerStream,
QTextStream& sourceStream)
{
closeIncludeGuard(baseName, headerStream);
writeFileFooter(headerStream);
writeFileFooter(sourceStream);
QIODevice* device = headerStream.device();
headerStream.unsetDevice();
delete device;
device = sourceStream.device();
sourceStream.unsetDevice();
delete device;
return true;
}
示例3: WriteConfigFile
//
// Write the data configuration element to the XML output stream. Call
// the appropriate configuration type-specific private function to actually
// perform the writing.
//
bool CDCConfig::WriteConfigFile(wchar_t *configFileName)
{
QFile* pFile = NULL ;
QTextStream xmlStream ;
if (m_configType == DCConfigInvalid) {
// No valid configuration data
return( false ) ;
}
pFile = new QFile( QString::fromUcs2((const short unsigned int*)configFileName) ) ;
if (! pFile->open( QIODevice::WriteOnly )) {
// Fill open error
return( false ) ;
}
xmlStream.setDevice( pFile ) ;
// Set XML file character encoding
xmlStream.setEncoding(QTextStream::UnicodeUTF8) ;
// xmlStream.setEncoding(QTextStream::Unicode) ;
xmlStream << "<?xml version=\"1.0\"?>\n" ;
xmlStream << "<!DOCTYPE dc_configuration SYSTEM \"dcconfig.dtd\">\n";
xmlStream << "<dc_configuration" ;
if (m_cpuType.isEmpty())
m_cpuType = getCurrentCpuType();
WriteStringAttr(xmlStream, "cpu_type", m_cpuType) ;
xmlStream << ">\n" ;
switch( m_configType ) {
case DCConfigTBP:
{
WriteTBP( xmlStream ) ;
break ;
}
case DCConfigEBP:
{
WriteEBP( xmlStream ) ;
break ;
}
case DCConfigTBPPerf:
{
WriteTBPPerf( xmlStream ) ;
break ;
}
default:
break;
}
xmlStream << "</dc_configuration>\n" ;
// Close file and deallocate QFile explicitly
xmlStream.unsetDevice() ;
pFile->close() ;
delete pFile ;
return( true ) ;
}