Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] Qt QDomElement::setAttribute sequential entry

[Solved] Qt QDomElement::setAttribute sequential entry

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 5.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shint
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fcrochik
      wrote on last edited by
      #2

      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.

      Certified Specialist & Qt Ambassador <a href="http://www.crochik.com">Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop... Qt everywhere!</a>

      1 Reply Last reply
      0
      • S Offline
        S Offline
        shint
        wrote on last edited by
        #3

        thank you. fcrochik.
        reply to me.

        to find the cause of 3-4 lines added.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fcrochik
          wrote on last edited by
          #4

          Just to make clearer, what I meant is that on a xml-based file format:

          @<ANYTAG c1="1" c2="2" c3="4"/>@

          should mean exact the same as:

          @<ANYTAG c3="4" c2="2" c1="1" />@

          Certified Specialist & Qt Ambassador <a href="http://www.crochik.com">Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop... Qt everywhere!</a>

          1 Reply Last reply
          0
          • S Offline
            S Offline
            shint
            wrote on last edited by
            #5

            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....

            1 Reply Last reply
            0
            • S Offline
              S Offline
              shint
              wrote on last edited by
              #6

              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");
              

              @

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on last edited by
                #7

                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.

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  shint
                  wrote on last edited by
                  #8

                  thank you. Volker.

                  I told you and fcrochik
                  has done so.... ;;;;

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved