Results 1 to 3 of 3

Thread: Should I use multiple or a single model(s)?

  1. #1
    Join Date
    Apr 2010
    Posts
    27
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Should I use multiple or a single model(s)?

    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...

    Qt Code:
    1. settingsModel = new QStandardItemModel;
    2.  
    3. QStandardItem *networkSettings = settingsModel->invisibleRootItem();
    4. // then build each of these items with children items later
    5. QStandardItem *globalSettings = settingsModel->invisibleRootItem();
    6. QStandardItem *thresholdSettings = settingsModel->invisibleRootItem();
    7. QStandardItem *channelSettings = settingsModel->invisibleRootItem();
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Should I use multiple or a single model(s)?

    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.

  3. #3
    Join Date
    Apr 2010
    Posts
    27
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Should I use multiple or a single model(s)?

    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

Similar Threads

  1. Multiple timers in single Application
    By Qt Coder in forum Qt Programming
    Replies: 47
    Last Post: 5th October 2012, 13:23
  2. Multiple appearances in a single ui file
    By zgulser in forum Qt Tools
    Replies: 1
    Last Post: 5th June 2009, 19:12
  3. Single QGLContext across multiple QGLWidgets
    By pseudosig in forum Qt Programming
    Replies: 2
    Last Post: 22nd June 2008, 23:13
  4. Single slot for multiple list boxes
    By Sheetal in forum Qt Programming
    Replies: 1
    Last Post: 15th April 2008, 06:53
  5. insertion of multiple items in a single row
    By grimbaum in forum Qt Programming
    Replies: 4
    Last Post: 17th November 2006, 05:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.