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

    Quote Originally Posted by agarny View Post
    I tried showEvent(), but that doesn't work for things I need to do with QTreeView for example.
    Why not ?
    Is your tree built after app reached showeEvent() ?

  2. #2
    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
    Why not ?
    Good question and question to which I would very much like to get an answer!

    Quote Originally Posted by totem View Post
    Is your tree built after app reached showeEvent() ?
    Well, clearly not, since for example scrollTo() doesn't work as expected when called from within showEvent(). It seems to me that QTreeView needs a bit more time to fully initialise itself which might explain why showing a dialog box just before calling scrollTo() makes scrollTo() to work...

  3. #3
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

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

    I have got things to work by displaying a dialog box just before doing to the autoresizing or scrolling, and it was fine
    Have you tried to qApp->processEvents(); instead of displaying dialog box ?

  4. #4
    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 stampede View Post
    Have you tried to qApp->processEvents(); instead of displaying dialog box ?
    Yes, I did at the time, but to no avail. I am going to revisit all of that today though and will see how it goes.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

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

    Please provide a test case where scrollTo() doesn't work as expected.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    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 wysota View Post
    Please provide a test case where scrollTo() doesn't work as expected.
    Ok, I am busy with a couple of other things right now, but will try to come up with a test case as soon as possible. Who knows, it might actually help me figuring out what is wrong with my code, if anything...

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

    Quote Originally Posted by agarny View Post
    It seems to me that QTreeView needs a bit more time to fully initialise
    Then try to detect the end of this loading process, and load you settings right after ?

  8. #8
    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).

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

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

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

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

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