PDA

View Full Version : Aim: Creation of list during runtime



QtAlexander
16th November 2010, 17:56
Hello there, my fellow programmers!
Yes, I'm newbie. Okay, straight too it.

This isn't a programming error, as much as a lack of understanding of where I go next.

I'm making a program, and among other things, I need to be able to generate a dynamic list during runtime based on parameters which change.
I want to generate a list of options for the user to choose from, during runtime. This is necessary, because the program needs to propose the best fit as often as possible.

It's a GPS system, where the user has to pick a predefined "area", or address as the one he occupies. This is done (as opposed to automatically choosing the closest one) because of the margin for fault in such GPSes.

I've written a class for the addresses, and will have each address as a unique object with a unique position data set.

These need to be proposed to the user based on the distance between himself and their position data. Simple calculation, but how do I code this without going into a "if / else if" frenzy?
It's really necessary to modulate it, since I might need about 200 of these objects.

Also, modulating the code would naturally allow me to add more of these address objects later without going into a fit of corrections.

Please help me in the right direction of generally what programming methods I would use here.

Thanks!

Best regards, QtAlexander

Timoteo
16th November 2010, 18:12
See Dijkstra's algorithm (http://en.wikipedia.org/wiki/Dijkstra's_algorithm) and think about what type of static data you can use to populate nodes. This is the stuff that GPS maps are made of. You need topology data, and a lot of it (unless you are using 10-digit grid to navigate everywhere - which isn't very user friendly unless you are targeting those with military training).

The first order of business would be to generate (or find) that static data that you need. Maybe the GPS system has the topology data already and exposes an interface to use it?

If I seem off-target or vague, that's because your question is extremely vague (and without any type of code). It's unclear if you are implementating GPS software or trying to interact with it.

marcvanriet
16th November 2010, 20:19
Hi,

I think your question is that you a list of addresses, but want to show only part of them to the user, or not ?

Where do you store the instances of your addresses ? You could use a QList< >.
Then you can easily travers this list, and copy the relevant addresses to a second list that you use to present the user.

Or you could present the relevant addresses to the user in list or in a QTreeview. You can create a list or treeview with two 'colums' and make the second column hidden. Put the address in the first colum, and put the data you need internally in your program in the second column. This list or treeview is generated dynamically based on the current position and your QList of addresses. When the user makes a selection, take the data from the invisible column to find out which one he selected.

Hope this helps,
Regards,
Marc