PDA

View Full Version : QListWidget is slow when an item is clicked in the list



sRB
30th October 2014, 05:52
Hi all,

I have a Qlistwidget with which i create a list consisting of 2 items. the contents for the list are displayed in a QTextbrowser placed beside it. I set the current row to first item so that by defaults it points to the first element. When i click on the 2nd item, It takes almost around 5 seconds to appear in the textbrowser. What could be the issue here?

This is my code:

_list = new QListWidget(this);
QListWidgetItem *item1 = new QListWidgetItem;
item1->setText("List Item 1");
_list->insertItem(0, item1);
QListWidgetItem *item2 = new QListWidgetItem;
item2->setText("List Item 2");
_list->insertItem(1, item2);
_list->setSelectionMode(QAbstractItemView::SingleSelectio n);

CONNECT(_list->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelect ion)),
SLOT(onFocusChanged()));
_list->setCurrentRow(0, QItemSelectionModel::SelectCurrent);

faldzip
30th October 2014, 06:28
I do not see any code with QTextBrowser here. I'm guessig that it's used in onFocusChanged() so you should show us this code too.

sRB
30th October 2014, 06:32
_helpBrowser = new QTextBrowser(this);


void focusChanged()
{
QListWidgetItem* const selectedItem = _list->selectedItems()[0];

if (_list->row(selectedItem) == 0)
{
// Show something
}
else
{
// show something
}
}

anda_skoa
30th October 2014, 08:23
And you are sure that the delay you are seeing is not caused by the // show something part?

Cheers,
_

sRB
30th October 2014, 09:51
Well.. May be it could be because of that. :confused:
Thanks..

anda_skoa
30th October 2014, 12:21
Well.. May be it could be because of that. :confused:
Thanks..

Well, you have not posted any of that code, so we can only assume that you have checked that it is not the cause.

Cheers,
_