PDA

View Full Version : QListWidget: how to get current Item (which was set programatically)



high_flyer
19th April 2007, 22:11
Hi,
I have a dialong that when pupping up,it will populate some lists by loading data from a file.
I have a Label, in which some selected items from the lists are shown.
The problem is, that when the dialog loads, all selections are done programmatically - with no user input, and everything I tried in order to read the current items from the list doesn't work.
The label will update only after I click or use keyboard on the lists.
Here is what I tried:
Setting the current item with:
setCurrentItem();
satCurrentRow();
setCurrentIndex(); -> which actually should work if one follows the docs since:


void QAbstractItemView::setCurrentIndex ( const QModelIndex & index ) [slot]

Sets the current item to be the item at index. Depending on the current selection mode, the item may also be selected. Note that this function also updates the starting position for any new selections the user performs.

To set an item as the current item without selecting it, call

So I would expect, that myList->currentItem() will retrieve that item.
But it doesn't.
Is there a way to select an item in a QListWIdget programmatically?
It must be possible - doesn't it?

high_flyer
19th April 2007, 22:23
I feagured it out.
My Bad.
The selection of the item occurs while the widget is not visible, and I show the slection only in case the widget was visible...

Thanks.