我决定在这写下自己每天获得的知识,有空可以当作翻翻的依据。内容尽管很杂。
SVG是一种用XML定义的语言,用来描述二维矢量及矢量/栅格图形。
enum QIODevice::OpenModeFlag
flags QIODevice::OpenMode
This enum is used with open() to describe the mode in which a device is opened. It is also returned by openMode().
Constant | Value | Description |
---|---|---|
QIODevice::NotOpen | 0x0000 | The device is not open. |
QIODevice::ReadOnly | 0x0001 | The device is open for reading. |
QIODevice::WriteOnly | 0x0002 | The device is open for writing. |
QIODevice::ReadWrite | ReadOnly | WriteOnly | The device is open for reading and writing. |
QIODevice::Append | 0x0004 | The device is opened in append mode, so that all data is written to the end of the file. |
QIODevice::Truncate | 0x0008 | If possible, the device is truncated before it is opened. All earlier contents of the device are lost. |
QIODevice::Text | 0x0010 | When reading, the end-of-line terminators are translated to '\n'. When writing, the end-of-line terminators are translated to the local encoding, for example '\r\n' for Win32. |
QIODevice::Unbuffered | 0x0020 | Any buffer in the device is bypassed. |
truncated
-
简明释义
-
更多资料
adj.
v.
bypassed
- v. 绕道,忽视(bypass的过去分词)
源码:写xml文件
#include "ui_mainwindow.h"
#include <iostream>
#include <QTextStream>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QFile *file=new QFile("/home/qust/qt/XML/1.xml");
if(!file->open(QIODevice::WriteOnly|QIODevice::ReadOnly))
{
return ;
}
QDomDocument doc;
QDomText text;
QDomElement element;
QDomProcessingInstruction instruction;
instruction=doc.createProcessingInstruction("xml","version=\'1.0\'");
doc.appendChild(instruction);
QDomElement root=doc.createElement("kdevelop");
doc.appendChild(root);
QDomElement general=doc.createElement("general");
root.appendChild(general);
element=doc.createElement("author");
text=doc.createTextNode("zeki");
element.appendChild(text);
general.appendChild(element);
element=doc.createElement("email");
text=doc.createTextNode("caizhiming@tom.com");
element.appendChild(text);
general.appendChild(element);
QTextStream out(file);
doc.save(out,4);
file->close();
}
MainWindow::~MainWindow()
{
delete ui;
}
运行后:
读xml源码:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtXml>
#include <QDebug>
#include <QFile>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QDomDocument dom;
QFile *file=new QFile("/home/qust/qt/XML/1.xml");
if(file->open(QIODevice::ReadOnly))
{
dom.setContent(file);
}
QDomNodeList email=dom.elementsByTagName("email");
qDebug()<<email.count();
qDebug()<<email.item(0).toElement().text();
// QDomNodeList general=kdevelop.item(0).toElement().childNodes();
//qDebug()<<general.item(0).toElement().text();
}
MainWindow::~MainWindow()
{
delete ui;
}