PDA

View Full Version : Logging to a file and using same model for diff views



steg90
10th May 2007, 15:06
Hi,

Is there any classes for doing logging of data to a file in Qt? I have looked at using QFile so far but just wondered if there is anything like the simple-log for java?

Also was wondering if it is possible to have one model which can be used by two seperate views, one view being a tableview, the other a treeview, I don't know if this is possible as the underlying data structures would be different and I guess?

Regards,
Steve

marcel
10th May 2007, 15:17
Is there any classes for doing logging of data to a file in Qt? I have looked at using QFile so far but just wondered if there is anything like the simple-log for java?

Go ahead and use QFile, there is no other class.



Also was wondering if it is possible to have one model which can be used by two seperate views, one view being a tableview, the other a treeview, I don't know if this is possible as the underlying data structures would be different and I guess?

I haven't heard of such thing. The best you can do is to share the data between the two models. But this way you will have to keep the data in a separate, independent structure and have both models update from it.

Regards

steg90
10th May 2007, 15:27
Ok, will just use QFile.

Thought using a model for different types of view would be strange, unless the views were similar. Guess I'd have to have two different models that share the data as you suggested.

Thanks,
Steve

croftj
10th May 2007, 16:15
I thought that was the point of the Model/View programming model. Assuming a model can fulfill the needs of the views, you can have all sorts of views pointing to the same model.

-joe


Ok, will just use QFile.

Thought using a model for different types of view would be strange, unless the views were similar. Guess I'd have to have two different models that share the data as you suggested.

Thanks,
Steve

wysota
10th May 2007, 23:16
Is there any classes for doing logging of data to a file in Qt? I have looked at using QFile so far but just wondered if there is anything like the simple-log for java?
I sometimes use Log4cpp.


Also was wondering if it is possible to have one model which can be used by two seperate views, one view being a tableview, the other a treeview, I don't know if this is possible as the underlying data structures would be different and I guess?

If you want only a single level of the tree displayed by the table view, then you can use the model directly on both views as already suggested. If you want to display all items in some different manner, use a proxy model that will transform the tree into a flat model (try this one here: http://www.thorsen-consulting.dk/download/tc-freeclasses-20051221.tar.gz ).