Results 1 to 4 of 4

Thread: QTextBrowser as logger

  1. #1
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QTextBrowser as logger

    Hi,

    I am using a Qtextbrowser to log/display messages from a device in my application. I used the append (QString &text) [slot] to add my messages to my logger. I noticed that that my app wont last 24 hours it will just crush I am suspecting that Qtextbrowser is just using up all memory my PC can afford.

    I want to run my apps for months, how can i control Qtextbrowser from eating up all my memory? or What is the better solution to my objective, to show messages to my user that will run for months.

    baray98

  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: QTextBrowser as logger

    Are you sure it is the QTextBrowser? You might have memory leaks in other parts of your application. How much data does it gather in 24 hrs?

    Anyway,if you want it to run for months, you should dump old data to disk since the log could grow to tens or hundreds of megabytes. You should display only a small part of the log. If the user scrolls the log then you have to load older/newer parts.

    Or you could split the log in smaller files on disk. For example one log file for each week. You should let the user choose what log to see - i.e. choose the week and you just load the corresponding log file.

    But you first must make sure there aren't any other problems.

    Regards

  3. #3
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTextBrowser as logger

    259200 lines per day is the message average rate

    I can even throw away the data every 1000 lines i just dont want it to crush.

    I am 80% sure that it is the textbrowser that is doing it cause there is no other else active.

    Now, my question is how can i limit the textBrowser to 1000 lines and then reset the browser?

    baray98

  4. #4
    Join Date
    Jan 2007
    Posts
    68
    Thanks
    9
    Thanked 8 Times in 8 Posts

    Default Re: QTextBrowser as logger

    Quote Originally Posted by baray98 View Post
    259200 lines per day is the message average rate

    I can even throw away the data every 1000 lines i just dont want it to crush.

    I am 80% sure that it is the textbrowser that is doing it cause there is no other else active.

    Now, my question is how can i limit the textBrowser to 1000 lines and then reset the browser?

    baray98
    300000 logs * 100 (avg. loglength) * 2 bytes (QChar) ~= 57MB

    qtextbrowser & qtextedit should be able to handle this, at least for one day, but it's absolutely insane to display & store your logs this way.

    how about setting up a database of your choice, where you store your logs,
    in your database you create a view, which shows the x newest logs.

    to display the logs in your qt applicatin you then use a QTableview/QTreeview and a QSqlTableModel/QSqlRelationalTableModel populating it with data from the databaseview.

Similar Threads

  1. Loading images in html in a QTextBrowser
    By BasicPoke in forum Newbie
    Replies: 1
    Last Post: 6th June 2007, 21:51
  2. QTextBrowser Problem
    By Cutey in forum Qt Programming
    Replies: 1
    Last Post: 19th January 2007, 10:19
  3. CSS in QTextBrowser
    By gesslar in forum Qt Programming
    Replies: 1
    Last Post: 4th April 2006, 09:17
  4. [QT4] QtextBrowser and image size (win)
    By sebgui in forum Qt Programming
    Replies: 0
    Last Post: 28th March 2006, 21:01
  5. how to adjust sizes of QTextBrowser?
    By Pan Wojtas in forum Qt Programming
    Replies: 2
    Last Post: 7th February 2006, 22:25

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.