抱歉令人困惑的标题,我正在尝试做的是用Qt计算具有某个标记名称的元素量。当我这样做时,并尝试将计数转换为我获得字母而不是数字的字符串。

void xml::list(QDomElement root, QString tagname, QString att){
QDomNodeList items = root.elementsByTagName(tagname); // node list of elements 
debug.setText(QString(items.count())); // converting the amount of elements to integer
debug.show(); // showing the popup box
}
.

只有一个元素应该计数,我应该在消息框中获得第1号,而是给我字母“r”。我是不正确的吗?

有帮助吗?

解决方案

使用QString::number(items.count())。您目前刚刚通过使用原始Unicode值隐式将整数局部转换为生意区icetagcode。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top