PDA

View Full Version : New member and a question about QListWidget



Pokepasa
30th October 2009, 16:50
Hi all.

I just register now and it is my first post here.

First my presentation: I'm from Spain and I'm trying to learn Qt in order to make multiplatform programs and program for Symbian S60 too.

Now the question:

I'm making a single program but cannot find the way to make the next issue:

I have a QListWidget with checkable items, and I want that when the user checks on one item, it hides automatically. I tried with on_lstList_itemSelectionChanged and with other slots, but it dont works well. It seems that this piece of code is executed before the item is checked (when I debug with QT Creator the signal comes when I just click on item, but the item is not checked until the slot finish), and dont works:


// If user checks an item, hide it.
void basket::on_lstList_itemSelectionChanged()
{
int i = ui->lstList->currentRow();
if (ui->lstList->item(i)->checkState() == Qt::Checked) {
ui->lstList->item(i)->setHidden(true);
}
}


Any ideas to this? Thanks in advice.

Lykurg
30th October 2009, 17:24
Hi,

try QListWidget::itemChanged(). It must be emitted when the check state changes, but I am not sure right now...

Pokepasa
4th November 2009, 10:24
Lykurg, sorry for the delay, I was ill.

Thank you very much, it works perfectly, as I wanted. I dont know why I was not able to associate itemChanged with change check item status before.

Thank you.