Results 1 to 6 of 6

Thread: efficient way to store menu items in file

  1. #1
    Join Date
    Aug 2008
    Posts
    60
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default efficient way to store menu items in file

    my Qt application requires to store the menu information (submenus, menuitems, shortcut keys, etc), to persist across sessions.
    Can you please suggest efficient way to store this in file?
    And how efficient QSetting is, in storing hierarchical data (without repeating the same info) ?
    Thank you.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: efficient way to store menu items in file

    Quote Originally Posted by h123 View Post
    And how efficient QSetting is, in storing hierarchical data (without repeating the same info) ?
    Good. See QSettings::beginGroup() with QSettings::beginWriteArray().

  3. #3
    Join Date
    Aug 2008
    Posts
    60
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: efficient way to store menu items in file

    Just for illustration, how efficiently the QTreeWidgetItems can be stored using QSetting, without repeating the info like...
    <example 'setting.txt' file>
    Line1: main_menu/File
    Line2: main_menu/File/Print
    ...
    Line 10: main_menu/Edit
    Line 11: main_menu/Edit/Copy
    ...

    Here I want to avoid reduandant information that it stores about 'main_menu' and 'File' or 'Edit'.

    Thank you.

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: efficient way to store menu items in file

    Right, I was false, I thought it would be making
    Qt Code:
    1. [Menu]
    2. [File]
    3. print = xyz
    4. ...
    To copy to clipboard, switch view to plain text mode 
    Then I think you have to use a custom file format (xml)

    or

    you can try create a hash with all your informations and use QDataStream & operator<< ( QDataStream & out, const QHash<Key, T> & hash ) (<- and vice versa, but I never have tested that...)

  5. #5
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: efficient way to store menu items in file

    for more compilcated tree structure you can use XML files with DOM API (to have random access to tree structure) or with XmlStreamReader and Writer wich can be better in your case to use reader to read the settings at the beggining and store them with writer at the end (application closing).
    Another way is to use SQLite to manage your settings database saved in file (like in the newest QtCreator). You can have than file e.g. settings.db and access it like a database - with SQL statements - and store settings there like in database.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  6. #6
    Join Date
    Aug 2008
    Posts
    60
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: efficient way to store menu items in file

    Thank you all for informaion..

    faldżip, thank you for suggesting xml option.
    I am just wondering how sqlite will be useful, as it stores data in relational manner not in hierarchical level ?

    Also, if you have any idea about the hierachical data type in C/C++ (I seem it mentioned in http://www.open-std.org/jtc1/sc22/wg...ierarchy.plain) lib then please let me know.

    Any idea, which is better in efficiency, JSON or xml ?

    Thank you.

Similar Threads

  1. Radio menu items in Designer
    By rbp in forum Qt Tools
    Replies: 0
    Last Post: 31st March 2009, 00:50
  2. Some menubar items can not be clicked
    By richardander in forum Qt Programming
    Replies: 4
    Last Post: 11th March 2009, 00:26
  3. designer not showing menu items ...
    By wagmare in forum Installation and Deployment
    Replies: 0
    Last Post: 24th February 2009, 10:26
  4. Replies: 2
    Last Post: 2nd April 2008, 17:28
  5. Want custom menu items, like graphics, but how?
    By rm in forum Qt Programming
    Replies: 1
    Last Post: 30th January 2008, 20:52

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.