Results 1 to 20 of 21

Thread: 'Best' Qt strategy for loading/saving user settings (esp. for QTreeView)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: 'Best' Qt strategy for loading/saving user settings (esp. for QTreeView)

    Quote Originally Posted by totem View Post
    Then try to detect the end of this loading process, and load you settings right after ?
    I have tried that too (by having a while loop with qApp->processEvents(); in it -- yes, it was a quick and dirty way of testing things at that stage), but to no avail. What I did, if I recall correctly was to test for QTreeView to be visible, but that didn't quite work as I expected (I seem to remember that things were hanging up, but I might have something wrong back then, can't remember for certain).

  2. #2
    Join Date
    Dec 2009
    Posts
    128
    Thanks
    7
    Thanked 14 Times in 14 Posts
    Platforms
    Unix/X11 Windows

    Default Re: 'Best' Qt strategy for loading/saving user settings (esp. for QTreeView)

    Indeed a loop on processEvents() does not seem clean
    If you have a treeview, you must have an associated model (or you meant treewidget?)
    Try to catch a signal from this model, indicating it finished to load its data; if you don't find such signal, try to implement something equivalent. Then you read treeview settings, after its data has been updated

  3. #3
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: 'Best' Qt strategy for loading/saving user settings (esp. for QTreeView)

    Quote Originally Posted by totem View Post
    Indeed a loop on processEvents() does not seem clean
    Well, I did warn you...

    Quote Originally Posted by totem View Post
    If you have a treeview, you must have an associated model (or you meant treewidget?)
    I do indeed have an associated model (a QFileSystemModel object).

    Quote Originally Posted by totem View Post
    Try to catch a signal from this model, indicating it finished to load its data; if you don't find such signal, try to implement something equivalent. Then you read treeview settings, after its data has been updated
    I am not aware of any such signal. I did, however, try to 'play' with the expanded() signal, but again to no avail.

    Anyway, I am nearly done with what I needed to do, so I should soon be able to resume that aspect of my work.

  4. #4
    Join Date
    Apr 2010
    Location
    Almaty
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 'Best' Qt strategy for loading/saving user settings (esp. for QTreeView)

    As i understand your problem not in settings your problem in show/hide some properties of widgets. You can do save to file (as txt) your needed widgets as boolean or in integers (with specific values) then when your program opens read them from file and show/hide needed widgets.

  5. #5
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: 'Best' Qt strategy for loading/saving user settings (esp. for QTreeView)

    Quote Originally Posted by meyrambek View Post
    As i understand your problem not in settings your problem in show/hide some properties of widgets. You can do save to file (as txt) your needed widgets as boolean or in integers (with specific values) then when your program opens read them from file and show/hide needed widgets.
    Sorry meyrambek, but I believe you misunderstood my problem. Also, I wouldn't personally recommend using a text file to save my settings. I much prefer to rely on QSettings for this.

  6. #6
    Join Date
    Apr 2010
    Location
    Almaty
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: 'Best' Qt strategy for loading/saving user settings (esp. for QTreeView)

    not as txt as xml is more good way

Similar Threads

  1. Loading and saving in-memory SQLITE databases
    By miraks in forum Qt Programming
    Replies: 10
    Last Post: 27th April 2010, 21:24
  2. XML saving settings
    By ^NyAw^ in forum Qt Programming
    Replies: 12
    Last Post: 12th May 2009, 17:05
  3. Saving settings to XML
    By arturo182 in forum Qt Programming
    Replies: 2
    Last Post: 8th March 2009, 11:10
  4. QDataStream and saving and loading QList
    By Noxxik in forum Qt Programming
    Replies: 3
    Last Post: 1st March 2009, 22:02
  5. saving settings does not work
    By MarkoSan in forum Qt Programming
    Replies: 4
    Last Post: 13th June 2008, 19:29

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
  •  
Qt is a trademark of The Qt Company.