Results 1 to 5 of 5

Thread: Logging to a file and using same model for diff views

  1. #1
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Logging to a file and using same model for diff views

    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

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Logging to a file and using same model for diff views

    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

  3. #3
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Logging to a file and using same model for diff views

    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

  4. #4
    Join Date
    Feb 2007
    Posts
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Logging to a file and using same model for diff views

    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

    Quote Originally Posted by steg90 View Post
    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

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

    Default Re: Logging to a file and using same model for diff views

    Quote Originally Posted by steg90 View Post
    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/dow...0051221.tar.gz ).
    Last edited by wysota; 11th May 2007 at 00:21.

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.