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. Which one is quicker?
QtWS25 Last Chance

Which one is quicker?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.0k 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.
  • I Offline
    I Offline
    I-sty
    wrote on last edited by
    #1

    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
    0
    • G Offline
      G Offline
      goblincoding
      wrote on last edited by
      #2

      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
      0
      • S Offline
        S Offline
        sidewinder
        wrote on last edited by
        #3

        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
        0
        • I Offline
          I Offline
          I-sty
          wrote on last edited by
          #4

          [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
          0
          • I Offline
            I Offline
            I-sty
            wrote on last edited by
            #5

            [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
            0

            • Login

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