PDA

View Full Version : QListView for "console window"?



bkastel1
20th November 2007, 15:57
Hello again,

i'm working on a simple dialog window that will use QListView (this is my first idea) for "printing" debug messages. Is this the right approach?
I was searching the net if someone already faced this kind of problem in Qt but i haven't found anything. I'm working on a socketServer which prints debug info to a file but i also want these info in a dialog window. Is my idea correct and good (using my own ListView with subclassing QListView, QStringList and QStringListModel) or does anybody have a better idea?

Thank you all

wysota
20th November 2007, 21:01
i'm working on a simple dialog window that will use QListView (this is my first idea) for "printing" debug messages. Is this the right approach?
It depends. QTextBrowser seems a straightforward candidate, but you might have some special requirements... Then QListView might become a good candidate as well...

bkastel1
21st November 2007, 09:45
Well, requirements are that text can be of different color for different messages (warnings, error, information). The only thing i'm wondering is should i deside to have a fixed number or lines that can be written or not (i think that this is the smart thing to do because i still have a log file where everything is saved). I will check the QTextBrowser and then a decision has to be made :)

Thank you and if someone has any additional tips... :)

wysota
21st November 2007, 10:54
Well, requirements are that text can be of different color for different messages (warnings, error, information).
That's not a problem for the text browser.

bkastel1
21st November 2007, 12:10
Well, i think that we have a winner :)

thank you

bkastel1
21st November 2007, 15:18
One question regarding QTextBrowser: is there a possibility to set the maximum line count - let's say that when this number is reached first lines are erassed so than new lines can be written?

Thank you

wysota
21st November 2007, 17:55
I'm not sure, in Qt3 you could do that. But you can always monitor the size of the displayed document and removes lines from the beginning of the document when it grows too large.

jpn
21st November 2007, 17:58
From QTextEdit docs:

If you want to limit the total number of paragraphs in a QTextEdit, as it is for example open useful in a log viewer, then you can use QTextDocument's maximumBlockCount property for that.

bkastel1
23rd November 2007, 12:33
I know this question will be probalby silly but hot to implement this property to QTextEdit? Should i inherit the QTextEdit and QTextDocument and make my own TextEdit? :confused:

Thank you

bkastel1
23rd November 2007, 13:23
Is this correct:

QTextEdit *textEdit = new QTextEdit();
QTextDocument *document = textEdit->document();

document->setMaximumBlockCount( n );

Thanky you

wysota
23rd November 2007, 13:29
QTextEdit uses QTextDoument internally. So you can access the widget's document and manipulate it without subclassing anything.

bkastel1
23rd November 2007, 14:19
One interesting remark: when i reach my maximumBlockCount (in my case 1000) i get processor spikes which are as high as 30% every time i add new text (i have a core2duo 2GHz with 2GB RAM). Any idea? i have a multithreaded application.

wysota
23rd November 2007, 15:51
The spikes are probably because the document has to go through the whole text and update it, relayout the whole document and do the highlighting (if you use it).

bkastel1
23rd November 2007, 16:00
Thank you. I will try to find a better way to do this... hopefully :)