Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/136.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用c++; 我用Qt4.4.3用C++。我想实现一个对象,并将其作为函数的返回值传递。我使用它的方式与QdomeElement对象相同,包括:_C++_Qt - Fatal编程技术网

如何使用c++; 我用Qt4.4.3用C++。我想实现一个对象,并将其作为函数的返回值传递。我使用它的方式与QdomeElement对象相同,包括:

如何使用c++; 我用Qt4.4.3用C++。我想实现一个对象,并将其作为函数的返回值传递。我使用它的方式与QdomeElement对象相同,包括:,c++,qt,C++,Qt,在以这种方式插入7个其他节点并从函数返回后,我注意到使用返回的QDomDocumentFragment调用节点并没有插入任何新的子节点。在使用函数中的以下代码进行调试后,我意识到没有节点实际插入到rootnode中: QMessageBox::information(this->owner, QObject::tr("Debug"), QObject::tr("Node has children: ")+QString::number(rootnode.childNodes().size(

在以这种方式插入7个其他节点并从函数返回后,我注意到使用返回的QDomDocumentFragment调用节点并没有插入任何新的子节点。在使用函数中的以下代码进行调试后,我意识到没有节点实际插入到rootnode中:

QMessageBox::information(this->owner, QObject::tr("Debug"), QObject::tr("Node has children: ")+QString::number(rootnode.childNodes().size()));

打印的消息是“节点有子节点:0”。我错过了什么?

好的,对不起,浪费了大家的时间。。看起来我需要使用以下方法创建文档片段:

QDomDocumentFragment rootnode = doc.createDocumentFragment();
QDomDocumentFragment rootnode = doc.createDocumentFragment();