本文整理汇总了C++中QXmlStreamWriter::setDevice方法的典型用法代码示例。如果您正苦于以下问题:C++ QXmlStreamWriter::setDevice方法的具体用法?C++ QXmlStreamWriter::setDevice怎么用?C++ QXmlStreamWriter::setDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QXmlStreamWriter
的用法示例。
在下文中一共展示了QXmlStreamWriter::setDevice方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rewriteXMLFile
int Generate_Xml::rewriteXMLFile(QVector<QLineEdit *> p,int j,int track_tabsibling)
{
bool tab;
int tab_get;
QFile Default("default1.xml");
QXmlStreamWriter *xmlWriter = new QXmlStreamWriter();
QXmlStreamWriter *newline = new QXmlStreamWriter();
xmlWriter->setDevice(&Default);
newline->setDevice(&Default);
xmlWriter->setAutoFormatting (true);
xmlWriter->setAutoFormatting(true);
tab=xmlWriter->autoFormatting();
xmlWriter->setAutoFormattingIndent(-10);
tab_get=xmlWriter->autoFormattingIndent();
if (!Default.open(QIODevice::Append))
{
/* show wrror message if not able to open file */
QMessageBox::warning(0, "Read only", "The file is in read only mode");
}
QString temp1;
QString temp2;
temp1=(p.at(j))->displayText();
newline->writeEndDocument();
for(int i=0;i<track_tabsibling;i++)//changed tab here actaully multiplied by two
xmlWriter->writeCharacters("\t");
xmlWriter->writeStartElement(temp1);
j++;
while(p.at(j)!=0)
{
temp1=(p.at(j))->displayText();
j++;
temp2=(p.at(j))->displayText();
j++;
xmlWriter->writeAttribute(temp1,temp2);
}
xmlWriter->writeEndElement();
Default.close();
delete xmlWriter;
delete newline;
return j;
}
示例2: SaveDocument
bool AEDocument::SaveDocument()
{
QFile file(projectFilePath());
if(!file.open(QIODevice::WriteOnly | QIODevice::Text))
return false;
QXmlStreamWriter* xmlWriter = new QXmlStreamWriter();
xmlWriter->setDevice(&file);
xmlWriter->writeStartDocument();
xmlWriter->writeStartElement("AnimaEditorProject");
SaveProjectData(xmlWriter);
SaveModels(xmlWriter);
xmlWriter->writeEndElement();
xmlWriter->writeEndDocument();
delete xmlWriter;
_newDocument = false;
return true;
}
示例3: startFile
bool HtmlExporter::startFile(QFile& file,
const QString& basename,
QXmlStreamWriter& stream,
int currentPage,
int totalPages)
{
if(!file.open(QIODevice::WriteOnly | QIODevice::Text))
{
errorHandler->handleIOError(file);
return false;
}
stream.setDevice(&file);
stream.setAutoFormatting(true);
stream.setAutoFormattingIndent(2);
stream.setCodec("utf-8");
// Get the CSS either from the resources or from the settings directory
writeHtmlStart(stream,
atools::settings::Settings::getOverloadedPath(":/littlenavmap/resources/css/export.css"));
writeHtmlHeader(stream);
writeHtmlNav(stream, basename, currentPage, totalPages);
stream.writeStartElement("table");
stream.writeStartElement("tbody");
return true;
}
示例4: writeConfigFile
bool ConfigXml::writeConfigFile(const QString fileName)
{
QXmlStreamWriter writer;
QFile configFile(fileName);
if (!configFile.open(QFile::Truncate | QFile::WriteOnly | QFile::Text)) {
qDebug() << "Error: Cannot write file " << qPrintable(fileName) <<
": " << qPrintable(configFile.errorString());
return false;
}
writer.setDevice(&configFile);
writer.setAutoFormatting(true);
writer.writeStartDocument();
writer.writeStartElement("config");
writeEntries(&writer);
writer.writeEndDocument();
configFile.close();
if (configFile.error()) {
qDebug() << "Error: Cannot write file " << qPrintable(fileName) <<
": " << qPrintable(configFile.errorString());
return false;
}
return true;
}
示例5: saveToFile
/*
Zapisuje ca³y kontener do pliku XML
Ka¿da para atrybut wartoœæ ma tak¹ sam¹ reprezentacjê w pliku XML.
Obiekty s¹ rozró¿niane za pomoc¹ tag'u rozpoczynaj¹cego który okreœla typ.
W przypadku komplikacji wyœwietlany jest MessageBox
*/
void MK::saveToFile(std::string filename){
QFile file(filename.c_str());
if (!file.open(QIODevice::WriteOnly)){
QMessageBox::warning(0,"B³¹d pliku",
"Plik jest zablokowany przed zapisem",
QMessageBox::Ok);
} else {
QXmlStreamWriter* xmlWriter = new QXmlStreamWriter();
xmlWriter->setDevice(&file);
xmlWriter->setAutoFormatting(true);
xmlWriter->writeStartDocument();
xmlWriter->writeStartElement("eksponaty");
MKontener::iterator mk_it;
QList<QPair<QString, QString> >::iterator it;
QList<QPair<QString, QString> > l_toFile;
mk_it = m_kontener.begin();
while( mk_it!=m_kontener.end() ){
l_toFile = (*mk_it)->saveElement();
it = l_toFile.begin();
xmlWriter->writeStartElement(l_toFile[1].second.simplified().replace(" ",""));
while (it != l_toFile.end() ){
xmlWriter->writeAttribute((*it).first.simplified().replace(" ",""),(*it).second);
it++;
}
xmlWriter->writeEndElement();
mk_it++;
}
xmlWriter->writeEndElement();
xmlWriter->writeEndDocument();
}
}
示例6: init
void init( QFile &file, QXmlStreamWriter &stream )
{
stream.setDevice( &file );
stream.setAutoFormatting(true);
stream.writeStartDocument("1.0");
stream.writeDTD("<!DOCTYPE IMAGE>");
stream.writeStartElement("image");
}
示例7: SaveFile
bool CParseChannelSettingConfig::SaveFile()
{
QString tempFile = "channel_temp.xml";
if( QFile::exists( tempFile ) )
{
if( !QFile::remove( tempFile ) )
return false;
}
QFile writeFile( tempFile );
if( !writeFile.open(QFile::ReadWrite| QFile::Text) )
return false;
QXmlStreamWriter XmlWrite;
XmlWrite.setDevice( &writeFile );
XmlWrite.setAutoFormatting( true );
XmlWrite.writeStartDocument();
XmlWrite.writeStartElement( ROOT_NODE );
int nCount = m_vecNewChannelSettingInfo.count();
for( int i=0; i<nCount; ++i )
{
CHANNEL_SETTING_INFO channelSettingInfo =m_vecNewChannelSettingInfo[i];
XmlWrite.writeStartElement( CHANNEL_NODE );
XmlWrite.writeTextElement( NUM_NODE, QString::number(channelSettingInfo.nChannelNum) );
XmlWrite.writeTextElement( QUALITY_NODE, QString::number(channelSettingInfo.enuQuality) );
XmlWrite.writeTextElement( RTMP_ENABLE_NODE1, QString::number(channelSettingInfo.bRtmpEnable1? 1:0) );
XmlWrite.writeTextElement( RTMP_ADDR_NODE1, channelSettingInfo.strRtmpAddr1 );
XmlWrite.writeTextElement( RTMP_AUDIO_DELAY_NODE1, QString::number(channelSettingInfo.nRtmpAudioDelay1) );
XmlWrite.writeTextElement( RTMP_ENABLE_NODE2, QString::number(channelSettingInfo.bRtmpEnable2? 1:0) );
XmlWrite.writeTextElement( RTMP_ADDR_NODE2, channelSettingInfo.strRtmpAddr2 );
XmlWrite.writeTextElement( RTMP_AUDIO_DELAY_NODE2, QString::number(channelSettingInfo.nRtmpAudioDelay2) );
XmlWrite.writeTextElement( UDP_RTP_ENABLE_NODE, QString::number(channelSettingInfo.bUdpOrRtpEnable? 1:0) );
XmlWrite.writeTextElement( UDP_RTP_ADDR_NODE, QString::number(channelSettingInfo.bUdpOrRtpAddr?1:0) );
XmlWrite.writeTextElement( UDP_RTP_IP_NODE, channelSettingInfo.strUdpOrRtpIp );
XmlWrite.writeTextElement( UDP_RTP_PORT_NODE, QString::number(channelSettingInfo.nUdpOrRtpPort) );
XmlWrite.writeTextElement( UDP_RTP_AUDIO_DELAY_NODE, QString::number(channelSettingInfo.nUdpOrRtpAudioDelay) );
XmlWrite.writeTextElement( INPUT_VIDEO_FORMAT_NODE, QString::number(channelSettingInfo.nInputVideoFormat));
XmlWrite.writeTextElement( OUTPUT_VIDEO_FORMAT_NODE, QString::number(channelSettingInfo.nOutputVideoFormat));
XmlWrite.writeEndElement();
}
XmlWrite.writeEndDocument();
writeFile.close();
// 临时文件写完后,将临时文件copy到备份文件
QString strSaveFile = CHANNEL_SETTING_CONFIG_FILE;
QFile::remove( strSaveFile );
bool bRet = QFile::rename( tempFile, strSaveFile );
sync();
return bRet;
}
示例8: file
void
SoundSettings::saveXML (
const QString &xmlFileName,
const QString &origFileName,
const QString ©FileName,
const QString &title)
{
QXmlStreamWriter *writer;
QFile file (xmlFileName);
SYS_DEBUG ("-----------------------------------------------------");
SYS_DEBUG ("*** xmlFileName = %s", SYS_STR(xmlFileName));
if (!file.open(QIODevice::WriteOnly)) {
SYS_WARNING ("Unable to open file for writing: %s",
SYS_STR(xmlFileName));
return;
}
/*
*
*/
writer = new QXmlStreamWriter();
writer->setDevice (&file);
writer->setAutoFormatting(true);
writer->setCodec ("UTF-8");
writer->writeStartDocument ();
writer->writeStartElement ("soundsettings-applet");
writer->writeStartElement("orig-file");
writer->writeCharacters (origFileName);
writer->writeEndElement ();
writer->writeStartElement("copy-file");
writer->writeCharacters (copyFileName);
writer->writeEndElement ();
writer->writeStartElement("title");
writer->writeCharacters (title);
writer->writeEndElement ();
/*
*
*/
writer->writeEndElement();
writer->writeEndDocument();
delete writer;
file.close ();
}
示例9: save_to_dir
bool NPushReportSpeed::save_to_dir(QString &dirName)
{
QString reportFilename = (dirName + FSC_FSYS_SLASH) + "Speed.xml";
QFile reportFile(reportFilename);
reportFile.open(QFile::WriteOnly | QFile::Text);
QXmlStreamWriter xml;
xml.setDevice(&reportFile);
xml.setAutoFormatting(true);
xml.writeStartDocument();
dataAccessMutex.lock();
xml.writeStartElement("SpeedReport");
xml.writeStartElement("stats");
xml.writeAttribute("max", QString::number(Speed_max));
xml.writeAttribute("avg", QString::number(Speed_avg));
xml.writeEndElement();//stats
xml.writeStartElement("graph");
SelfShrinkingList::iterator it;
for(it = graphPoints.begin(); it != graphPoints.end() ; ++it)
{
xml.writeStartElement("point");
xml.writeAttribute("val", QString::number(*it));
xml.writeEndElement();
}
xml.writeEndElement();//graph
xml.writeEndElement();//SpeedReport
dataAccessMutex.unlock();
xml.writeEndDocument();
reportFile.close();
qDebug() << "Speed -> Ended";
return true;
}
示例10: createCurrentConfigurationString
/**
* Creates the current configuration string.
* @return
* The string.
*/
QString CreateSceFile::createCurrentConfigurationString()
{
QBuffer xmlBuffer;
QXmlStreamWriter xmlWriter;
xmlWriter.setAutoFormatting(true);
xmlWriter.setAutoFormattingIndent(2);
xmlBuffer.open(QIODevice::WriteOnly);
xmlWriter.setDevice(&xmlBuffer);
xmlWriter.writeStartElement("SceConfiguration");
xmlWriter.writeStartElement("Files");
for(int i = 0; i < ui->filesTableWidget->rowCount(); i++)
{
QComboBox* box = static_cast<QComboBox*>(ui->filesTableWidget->cellWidget(i, COLUMN_TYPE));
QString subDirectory = ui->filesTableWidget->item(i, COLUMN_SUBDIR)->text();
QString source = MainWindow::convertToRelativePath(m_configFileName, ui->filesTableWidget->item(i, COLUMN_SOURCE)->text());
xmlWriter.writeStartElement("File");
xmlWriter.writeAttribute("subDirectory", subDirectory);
xmlWriter.writeAttribute("type", box->currentText());
xmlWriter.writeAttribute("source", source);
xmlWriter.writeEndElement();
}
xmlWriter.writeEndElement();
xmlWriter.writeStartElement("ScriptArguments");
for(int i = 0; i < ui->argumentsListWidget->count(); i++)
{
xmlWriter.writeStartElement("ScriptArgument");
xmlWriter.writeAttribute("value", ui->argumentsListWidget->item(i)->text());
xmlWriter.writeEndElement();
}
xmlWriter.writeEndElement();
xmlWriter.writeStartElement("ScriptWindowState");
xmlWriter.writeAttribute("withScriptWindow", QString("%1").arg(ui->withScriptWindowCheckBox->isChecked()));
xmlWriter.writeAttribute("notMinimized", QString("%1").arg(ui->notMinimized->isChecked()));
xmlWriter.writeAttribute("minScVersion", QString("%1.%2").arg(ui->minScVersionMajor->value()).arg(ui->minScVersionMinor->value()));
xmlWriter.writeAttribute("sceFileName", MainWindow::convertToRelativePath(m_configFileName, ui->fileLineEdit->text()));
xmlWriter.writeEndElement();
xmlWriter.writeEndElement();//SceConfiguration
return xmlBuffer.data();
}