×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    6

    dynamiclist with total sum??

    HI everyone,

    I am exploring the example from the SDK called dynamiclistview:
    I am learning to create my e-store based on qt quik.
    So far I have adopted the below example for:
    - chosing the quantity of items (added quantity property to the model)
    - calculating total amount per position (via Number(cost*quantity) function)

    Now problem I have is that I need a total sum for all the positions, meaning I need to sum up all the items's amounts, something like: Number(cost*quantity*all)

    Obviously a noob question - but any help or a link where to get an example is very appreciated!

  2. #2
    Registered User
    Join Date
    May 2009
    Location
    Guatemala
    Posts
    186

    Re: dynamiclist with total sum??

    You are probably going to need to loop through the model items (in javascript) to make the calculation. Look at the ListModel's get method in the documention.

    On the other hand, static models like the ones used in most of the examples are most of the times not useful for real applications, and you are probably going to switch to a model populated from a database at some point, in which case, you could calculate the total amount when populating the model.

    HTH
    -CarlosDL

  3. #3
    Registered User
    Join Date
    Apr 2009
    Posts
    6

    Re: dynamiclist with total sum??

    Hey, thanks a lot - I see what you mean...you are right right now I am doing this based on a local loop and idea is the actual price list is taken from the web...anyway thanks for the direction!

    PS: update - for the sake of offline demo I do - I used get as text output:
    Text {
    id: blabla
    text: myModel.get(0).cost * myModel.get(0).quantity

    and as I needed it to work to sum up all 6 of the items in the model I just summed them up))

    text: (myModel.get(0).cost * myModel.get(0).quantity) + (myModel.get(1).cost * myModel.get(1).quantity)

    Pretty lame but is good for the demo sake. I will now try to do this online with proper approach...
    Last edited by cmer4; 2011-04-20 at 05:37.

Similar Threads

  1. Error!!Sum Help
    By Jibrael in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2010-03-26, 13:48
  2. total failure with S60 emulator
    By kevinpw in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2010-02-20, 18:21
  3. No sum function ?
    By napot in forum Symbian
    Replies: 3
    Last Post: 2009-10-26, 10:23
  4. starting with python,having sum prob!
    By prashantghabak in forum Symbian
    Replies: 8
    Last Post: 2009-06-19, 21:10
  5. Need help when building DynamicList
    By LvChong in forum Symbian User Interface
    Replies: 0
    Last Post: 2005-07-21, 02:27

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×