[Solved] Qt QDomElement::setAttribute sequential entry
-
i make code.
@
//sample code
QDomElement e;
QVariant vCol = im->headerData(col, Qt:: Horizontal, Qt:: DisplayRole);
QModelIndex index = im->index(row, col, QModelIndex());
e.setAttribute("C1", "data");
e.setAttribute("C2", "data");
e.setAttribute("C3", "data");
e.setAttribute("C4", "data");
e.setAttribute("C5", "data");
@i think. output that C1, C2, C3, C4, C5.
but, output document is...
@
C5, C2, C3, C4, C1
@i would like to know. how to order the output.
please. help me in this regards. -
I don't know if it is possible or not but it is probably a bad idea to have a parser that expects attributes to be on any given order. It is supposed to be a human readable/editable format...
By the way including lines 3-4 on your example will only confuse people trying to help you.
-
thank you. fcrochik.
you're good man.
first i don't speak english;;;; please. understand me;;;i think. so same.
you talk. this way. maybe need remember. each item name.
the reason i ask this question.
because. i need sequence number that match the name and data.so.
this way. maybe. need parsing read and write data.
though.
i want to know.... T_T... how to sequential entry.... -
i tested code.
but. if first name is number. cannot read document file;;;;OK is success code.
BAD is fail code.OK
@
im->setHeaderData(0, Qt::Horizontal, "C_1");
im->setHeaderData(1, Qt::Horizontal, "C_2");
im->setHeaderData(2, Qt::Horizontal, "C_3");
im->setHeaderData(3, Qt::Horizontal, "C_4");
im->setHeaderData(4, Qt::Horizontal, "C_5");im->setHeaderData(0, Qt::Horizontal, "Ca_1"); im->setHeaderData(1, Qt::Horizontal, "Ca_2"); im->setHeaderData(2, Qt::Horizontal, "Ca_3"); im->setHeaderData(3, Qt::Horizontal, "Ca_4"); im->setHeaderData(4, Qt::Horizontal, "Ca_5"); im->setHeaderData(0, Qt::Horizontal, "1_shape"); im->setHeaderData(1, Qt::Horizontal, "2_tension"); im->setHeaderData(2, Qt::Horizontal, "3_temp"); im->setHeaderData(3, Qt::Horizontal, "4_mine"); im->setHeaderData(4, Qt::Horizontal, "5_donut"); im->setHeaderData(0, Qt::Horizontal, "1C_shape"); im->setHeaderData(1, Qt::Horizontal, "2C_tension"); im->setHeaderData(2, Qt::Horizontal, "3C_temp"); im->setHeaderData(3, Qt::Horizontal, "4C_mine"); im->setHeaderData(4, Qt::Horizontal, "5C_donut");
@
BAD
@
im->setHeaderData(0, Qt::Horizontal, "C1");
im->setHeaderData(1, Qt::Horizontal, "C2");
im->setHeaderData(2, Qt::Horizontal, "C3");
im->setHeaderData(3, Qt::Horizontal, "C4");
im->setHeaderData(4, Qt::Horizontal, "C5");im->setHeaderData(0, Qt::Horizontal, "C1a"); im->setHeaderData(1, Qt::Horizontal, "C2a"); im->setHeaderData(2, Qt::Horizontal, "C3a"); im->setHeaderData(3, Qt::Horizontal, "C4a"); im->setHeaderData(4, Qt::Horizontal, "C5a"); im->setHeaderData(0, Qt::Horizontal, "C_1a"); im->setHeaderData(1, Qt::Horizontal, "C_2a"); im->setHeaderData(2, Qt::Horizontal, "C_3a"); im->setHeaderData(3, Qt::Horizontal, "C_4a"); im->setHeaderData(4, Qt::Horizontal, "C_5a"); im->setHeaderData(0, Qt::Horizontal, "shape_1"); im->setHeaderData(1, Qt::Horizontal, "tension_2"); im->setHeaderData(2, Qt::Horizontal, "temp_3"); im->setHeaderData(3, Qt::Horizontal, "mine_4"); im->setHeaderData(4, Qt::Horizontal, "donut_5");
@
-
Attributes of tags are not ordered in XML. This is clearly stated in the XML specs:
bq. http://www.w3.org/TR/REC-xml/#sec-starttags
Note that the order of attribute specifications in a start-tag or empty-element tag is not significant.So you have no chance to enforce your attributes into any order of your will.
If your application depends on the order of data, put them into elements (tags) of their own. These are ordered.