Question

Sorry for the confusing title, what I am trying to do is use Qt to count the amount of elements with a certain tag name. When I do this, and try to convert the count to a string I get letters instead of numbers.

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
}

there is only one element that it should be counting, and I should get the number 1 in the message box, instead it gives me the letter "r". Am I converting this incorrectly?

Was it helpful?

Solution

Use QString::number(items.count()). You are currently just implicitly converting the integer to a QChar by using the raw unicode value.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top