qt 学习笔记(1) xml

news/2024/5/19 0:13:44 标签: qt, attributes, xml, function, signal, access

qt 获得xml 节点属性,

The QDomAttr class represents one attribute of a QDomElement.  //描绘,(抽象地)表现 2. 象征;表示 3. 作为...的代表 4.

For example, the following piece of XML produces an element with no children, but two attributes:

 <link href="http://qt.nokia.com" color="red" />

You can access the attributes of an element with code like this:

 QDomElement e = //...
 //...
 QDomAttr a = e.attributeNode("href");
 cout << a.value() << endl;                // prints "http://qt.nokia.com"
 a.setValue("http://qt.nokia.com/doc"); // change the node's attribute
 QDomAttr a2 = e.attributeNode("href");
 cout << a2.value() << endl;               // prints "http://qt.nokia.com/doc"

This example also shows that changing an attribute received from an element changes the attribute of the element. If you do not want to change the value of the element's attribute you must use cloneNode() to get an independent copy of the attribute.

QDomAttr can return the name() and value() of an attribute. An attribute's value is set with setValue().



//The readyRead() signal is emitted every time a new chunk of data has arrived.//数据块

属性的添加:

QDomAttr QDomElement::setAttributeNode ( const QDomAttr & newAttr )

Adds the attribute newAttr to this element.

If the element has another attribute that has the same name as newAttr, this function replaces that attribute and returns it; otherwise the function returns a null attribute.

新建属性:

QDomAttr QDomDocument::createAttribute ( const QString & name )

Creates a new attribute called name that can be inserted into an element, e.g. using QDomElement::setAttributeNode().

现在遇到不能修改XML文件,apt说要用.ini文件保存参数。QSetting 类。



http://www.niftyadmin.cn/n/1736337.html

相关文章

QT 使用QSettings 读写ini配置文件

qt 中如果想要保存参数&#xff0c;可选用QSettings类生成.ini文件保存参数 源程序&#xff1a; #include "mainwindow.h"#include "ui_mainwindow.h"#include <QSettings>MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui…

QtableWIdgetitem中出现编辑光标

render&#xff1a; 1. 使得,使成为 2. 给予,提供[(to)] Render 1.着色或渲染 int rowui->tableWidget->currentRow();//获得当前tablewidgetitem QTableWidgetItem *itemui->tableWidget->item(row,1); ui->tableWidget->editItem(item);//能出现编辑的光…

QVariant

QVariant 类&#xff0c;类似于C的联合数据类型&#xff0c;他能保存很多Qt数据。 声明&#xff1a; v QVarient ("hello world"); QString stringv.toString(); 先声明&#xff0c;然后调用相关的函数就行了。 它好多可供转化的函数&#xff1a; QVariant () …

QT 程须知道的

Qt程序一般格式&#xff1a; #ifndef SHOWLIST_H #define SHOWLIST_H namespace Ui { class ShowList;//前置声明ShowList 类 } namespace是用来解决C的名字冲突问题的 名字空间名必需是唯一的&#xff0c;否则必需在它们的外面再套上一层名字空间&#xff0c;名字空间可以和…

QT QUdpSocket的连接判断以及错误显示

if you need a socket, you have two options: 1.Instantiate QTcpSocket or QUdpSocket //实例化 2.Create a native socket descriptor, instantiate QAbstractSocket, and call setSocketDescriptor() to wrap the native socket. Internally 1.在内部&#xff0c;内存 i…

ARM启动代码学习(一)RO和RW还有ZI代表什么?(转载)

一般而言&#xff0c;一个程序包括只读的代码段和可读写的数据段。在ARM的集成开发环境中&#xff0c;只读的代码段和常量被称作RO段(ReadOnly)&#xff1b;可读写的全局变量和静态变量被称作RW段(ReadWrite)&#xff1b;RW段中要被初始化为零的变量被称为ZI段(ZeroInit)。对于…

Oracle EBS 通过API创建的供应商的采购订单无法计税

Oracle Applications : 12.1.3 通过API创建供应商、供应商地点和税详细信息,使用该供应商地点创建PO未计税。但是,手工创建的供应商地点和税详信息的PO就能够计税,二者对比是前端界面一模一样。 供应商->税详细信息->供应商地点>更新事务处理税 检查涉及税相关表如…

ubuntu11.10 系统下系统没有声音及Gentoo上的ALSA

今天ubuntu 11.10 下突然没了声音&#xff0c;结果sudo /sbin/alsa force-reload就解决问题了&#xff0c;但不知道为什么。 原文连接 点击打开链接 什么是ALSA   ALSA是Advanced Linux Sound Architecture&#xff0c;高级Linux声音架构的简称,它在Linux操作系统上提供了音…