开发者

Saving user's data for my application part 2

开发者 https://www.devze.com 2023-03-09 13:41 出处:网络
My first question was: should I use dom, sax, or sqlite to save the data the user is inputting into my application. The answer I am going with is to use DOM.

My first question was: should I use dom, sax, or sqlite to save the data the user is inputting into my application. The answer I am going with is to use DOM.

My second question is: How should I load the contents of the file into the application when the user decides to open the file? Should it go through the whole file and distribute all the data to the correct spots in the GUI once the user clicks "open" on the file? Or should it only open the stuff up as the user clicks on certain areas?

My third question is: How does qt handle knowing when things have changed? How would i know when the user has changed something and ask them to save the file?

If you do not understand, please let me know and I will try to explain again.


Example:

I am not only reading gui locations. But the contents of those. For instance. The user is able to create tabs that contain edit text boxes. And those tabs are associated with items that are in a list. When the user clicks on an item in the list the user will be presented with a whole set of new tabs. And each tab has some editing forms. The file will need to 开发者_开发问答contain what is in the list, what tabs the user has created under each item in that list and the contents of each tab associated with the tab of each item in the list.

Sorry that I posted another question that is similar to my last, but the other question was answered and now I need a new post.


Question 2: This very much depends on how much data you're dealing with. It will be much easier to load everything in one step. If you are expecting complex documents, it might be better to do it incrementally, but I would strongly recommend starting with the simpler approach.

Question 3: Qt does not handle this, except in as far as widgets will fire signals when they are modified. You need to do it, using a model of some sort. You could just use the DOM document directly as the model, although it may help maintainability to abstract the save format. Each change the user makes would cause a change in the model. You will need to detect when e.g. the user edits some text, update your model appropriately and keep track of whether it has changed since the last save.


What do you want to achieve with your solution? If you want to simply set Configuration why not using a simple Ini file (QSettings Class).

I don't know your application, but you should be able to recognise changes (lets say, if the user changed a QLineEdit or hit a radioButton).

There would be also a "sync" method for QSettings, which "rereads" the file you are working with. Qt won't recognise changes itself, you have to do that on your own.

0

精彩评论

暂无评论...
验证码 换一张
取 消