QListView for "console window"?
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
Re: QListView for "console window"?
Quote:
Originally Posted by
bkastel1
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...
Re: QListView for "console window"?
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... :)
Re: QListView for "console window"?
Quote:
Originally Posted by
bkastel1
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.
Re: QListView for "console window"?
Well, i think that we have a winner :)
thank you
Re: QListView for "console window"?
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
Re: QListView for "console window"?
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.
Re: QListView for "console window"?
From QTextEdit docs:
Quote:
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.
Re: QListView for "console window"?
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
Re: QListView for "console window"?
Is this correct:
QTextEdit *textEdit = new QTextEdit();
QTextDocument *document = textEdit->document();
document->setMaximumBlockCount( n );
Thanky you
Re: QListView for "console window"?
QTextEdit uses QTextDoument internally. So you can access the widget's document and manipulate it without subclassing anything.
Re: QListView for "console window"?
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.
Re: QListView for "console window"?
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).
Re: QListView for "console window"?
Thank you. I will try to find a better way to do this... hopefully :)