Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Which one is quicker?

    General and Desktop
    3
    5
    1758
    Loading More Posts
    • 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.
    • I
      I-sty last edited by

      Hi all,

      JUST THEORY.

      I have a struct called "mainStruct" with three records. -> mainStruct { QString pname, pcmd, pid};
      The struct has 'n' rows. I don't known how much. ( 10 > ~ < 100)
      I would like to refresh the "list".
      How to?

      At each step I overwriting the struct or, I search what cells are changed/removed/added and changed just these cells? This is a long time because I will have much if.

      What is the best choice?

      Sorry, for my bad English. My first language is Hungarian.

      1 Reply Last reply Reply Quote 0
      • G
        goblincoding last edited by

        If I were you (since it seems to me as if you have a unique pid for each struct):

        1. I'd change the struct to a small class that emits a "hasChanged( pid )" signal any time any of its internal variables change.
        2. Stick the structs (now small classes) into a map (pid as key).
        3. Connect the hasChanged() signal to a slot that updates the map based on the received pid (key).

        I hope that makes sense...I'm a bit pressed for time right now so will leave it at that.

        http://www.goblincoding.com

        1 Reply Last reply Reply Quote 0
        • S
          sidewinder last edited by

          If you have time to experiment then try and implement different approaches to your problem. You can use QTestLib to take some "measurements":http://qt-project.org/doc/qt-4.8/qtestlib-manual.html#creating-a-benchmark and compare numbers.
          IMHO, if data structure is really so simple, if row count will be held between 10 and 100 and you are not going to run your program on some embedded device or anything really slow then you most likely won't see much difference in speed if any.

          "Never memorize what you can look up in books."
          Albert Einstein

          1 Reply Last reply Reply Quote 0
          • I
            I-sty last edited by

            [quote author="goblincoding" date="1342608039"]If I were you (since it seems to me as if you have a unique pid for each struct):

            1. I'd change the struct to a small class that emits a "hasChanged( pid )" signal any time any of its internal variables change.
            2. Stick the structs (now small classes) into a map (pid as key).
            3. Connect the hasChanged() signal to a slot that updates the map based on the received pid (key).

            I hope that makes sense...I'm a bit pressed for time right now so will leave it at that.[/quote]

            Thanks goblin. I will try your idea.

            Sorry, for my bad English. My first language is Hungarian.

            1 Reply Last reply Reply Quote 0
            • I
              I-sty last edited by

              [quote author="sidewinder" date="1342615854"]If you have time to experiment then try and implement different approaches to your problem. You can use QTestLib to take some "measurements":http://qt-project.org/doc/qt-4.8/qtestlib-manual.html#creating-a-benchmark and compare numbers.
              IMHO, if data structure is really so simple, if row count will be held between 10 and 100 and you are not going to run your program on some embedded device or anything really slow then you most likely won't see much difference in speed if any.[/quote]

              Yes, I have time. ( I'm on summer holiday). So I will try also your idea.

              Sorry, for my bad English. My first language is Hungarian.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post