[Qt-interest] Widget to use on Model/View
João Mesquita
jmesquita at gmail.com
Thu Aug 20 07:03:26 CEST 2009
Hello guys, this is my first post so I am sorry if there is something
obvious I am missing.
I am developing an application that has a console like interface and I
thought of using QListView to represent this console. Each line on the
console would be an item that is then appended to the QListView model. The
advantage of using such a widget is that the console log messages can be
sorted easily. I could easily make checkboxes to hide certain messages that
do not belong to certain log levels or apply Regex or even filters using a
custom QSortProxyModel. If anyone is familiar with Wireshark, that is
exactly the same behavior I am trying to achieve.
Problem here is performance. When sorting, not a problem, but when inserting
a large number of lines per second, I make the UI unresponsive and even
unusable. Should I change the widget, the model or not possible at all?
Here is the code I am using (modified batch append code of QListWidget).
void ConsoleTabWidget::timerEvent(QTimerEvent *e)
{
bool scroll = false;
if (e->timerId() == scrollTimer->timerId())
{
if (m_ui->consoleListView->verticalScrollBar()->value() ==
m_ui->consoleListView->verticalScrollBar()->maximum())
scroll = true;
int inserted_items = 0;
while( !_list_items.isEmpty() && inserted_items < batch)
{
sourceModel->appendRow(_list_items.takeFirst());
inserted_items++;
}
if (scroll)
m_ui->consoleListView->scrollToBottom();
}
}
Any help would be wonderful!
Thank you,
jmesquita
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090820/c02e7a53/attachment.html
More information about the Qt-interest-old
mailing list