PDA

View Full Version : Should I use multiple or a single model(s)?



Cotlone
6th May 2010, 01:28
Hey everyone,
I am developing an application for communication with a data acquisition board. I would like to save settings for the board in the program, and I'd like to know whether it would be better to use multiple models to handle different setting groups or to set up some form of hierarchical model with all the settings. For example I have some threshold settings and network settings (among others) and I wonder if I can set a view to only display part of the model (e.g. a list of thresholds). I guess I thought it would be nice to keep of the data together within the code but I'm not sure if this is possible.

Here is what I am in the midst of setting up at the moment, but I'm not sure if it is the right way to go about it...




settingsModel = new QStandardItemModel;

QStandardItem *networkSettings = settingsModel->invisibleRootItem();
// then build each of these items with children items later
QStandardItem *globalSettings = settingsModel->invisibleRootItem();
QStandardItem *thresholdSettings = settingsModel->invisibleRootItem();
QStandardItem *channelSettings = settingsModel->invisibleRootItem();




Does anyone have any input on this issue, thanks in advance for your help?
- Michael

ChrisW67
6th May 2010, 02:21
If your editing view is based on QTreeView then you can easily show on a sub-section of the tree with QAbstractItemView::setRootIndex () (may also work for QListView).

I am assuming that your needs cannot be met by QSettings.

Cotlone
7th May 2010, 03:39
Awesome, thanks for your help Chris. I didn't realise that QSettings existed, but it seems it may not suffice.

For one aspect, my editing view will be based on QTableView, as I want the user to be able to view/ modify a 2D list of settings (as there are a number of channels, each of which has individual settings). For the rest, I was considering using a non-view based approach, as in just a collection of buttons/ combo boxes and so on.
- Michael