PDA

View Full Version : Using Qt in an application with lots of parameters



Bookmarc
3rd November 2008, 20:49
Hi,

I am working on a scientific application that has a lot (approx. 200) of different parameters. Each of these parameters has a type (double, int, choice list, etc.), a name, a list of dependencies, a unit (mm, velocity), etc.

All these parameters can be organized in different groups. The number of parameters can also change depending of the user input, so I need to be able to add new parameters at runtime.

Each time a parameter is changed (by the user, or by the application itself) it needs to notify it's dependent list to recalculate a bunch of stuff.

I was wondering if any of you had work on such system and how you used Qt to help you in this task.

I was maybe thinking of using QEvents for the notification part. (One thing that I'm not really sure, is that the parameters are organized like a graph and not like a tree... so there is a possibility of infinite loops when doing notifications).

Do you think the Qt MVC would be of any help here? What would be the benefit of using Qt MVC in this kind of problem... Those of you using Qt MVC are using it to solve what kind of problems?

I want to be able to access the values as directly as possible to perform all the calculations... For example, the QVariant type wouldn't really help me here.

The system is quite large and I want to be sure to pick the right thing before going in a 6-8 months of development!

Thanks,

Marc

wysota
3rd November 2008, 21:52
You can use one of broadcasting algorithms. An easy solution would be to assign each notification an increasing unique number and transmit the notification to all ones dependencies. Then each module would check if its last handled notification is greater or equal the currently received one. If so, it would ignore it. Otherwise it would handle it, update its notification counter and submit the notification to all its deps. You would then make sure you handle each notification only once and that you handle them in increasing order (so you would never handle a notification older than the last handled one).