PDA

View Full Version : saving files for future use on different computers running the same application



prolink007
11th June 2011, 17:29
I would like the ability for my application to save the layout and contents of the layouts when the user clicks save in my application. I would like the application to save them when the user clicks save. I would also like the user to have the ability to move to a different machine and run the application and load the file they saved. And when loaded, their layouts would all appear with the contents of those layouts.

How can i do this? And what would be the easiest and most proper way to do this? Right now, i am using DOM and just saving everything to a xml file. However, i just feel like there must be a different and easier way to do this. Can someone please enlighten me?

Thanks in advance, any comments and help is greatly appreciated!

Santosh Reddy
12th June 2011, 02:33
You could also use QSettings..

prolink007
12th June 2011, 05:27
Could you give me an example of how that would work. I took a look at the documentation and i really need a little bit of an example to go with it, have any examples at hand? Or is anyone able to show me an example of what i need using the settings?

If anyone has any other ideas on a way to accomplish what i want, please say so. Thanks!

Santosh Reddy
12th June 2011, 08:37
If you want an example how to use the QSettings the documentation gives it.

prolink007
12th June 2011, 17:21
Well from what i am seeing from that document is that it is going to load these settings into the registry. I need this stuff saved to a file that can be carried with the person to other machines running the application. Settings does not seem to offer this.

Before i asked this question i have been using DOM and xml stuff to save all the layout types and their contents and just loading all that when the user clicks load file and selects their file. But it just seems like there would be an easier way.

wysota
12th June 2011, 17:36
Settings does not seem to offer this.
Sure it does.


Before i asked this question i have been using DOM and xml stuff to save all the layout types and their contents and just loading all that when the user clicks load file and selects their file. But it just seems like there would be an easier way.
You can use QMainWindow::saveState() and QWidget::saveGeometry() and their counterparts to get rid of some of the work.

prolink007
12th June 2011, 21:49
Ok, so if the user inputs data into an edit text box, some of QSettings methods should be able to handle saving this information?

I am looking through the documentation and i must be missing the part where i can save this to a file specified by the user. For instance, the user just got through creating some tabs in their layout and then input some data into edit text boxes on those tabs (all within mainwindow). Now they want to save the layout and contents of what they just input to a file. They click save and then go to a different computer and want to load that stuff there. How is QSettings going to do this? I just keep seeing it doing stuff with the registry.

Sorry, i am just really confused. I am going to read it some more, but if you have input i would greatly appreciate further assistance! =)

SixDegrees
12th June 2011, 22:21
You can tell QSettings to input/output from an external file.

prolink007
12th June 2011, 22:42
Using this: QSettings::QSettings ( const QString & fileName, Format format, QObject * parent = 0 )

Is it that simple or is there something else?

wysota
13th June 2011, 00:36
It is that simple.