PDA

View Full Version : extracting a item from a QListWidget question



impeteperry
27th January 2007, 05:47
I have a QListWidget lwFoo whch cantains a column of QString items.
I double clicked on an item and got an index, but what I want is the item itself. In Ot3 terminalogy the "text"!!!.

I can't make heads or tails of documentation to do this.
I would appreciate is if someone could give me the code or explain the documentation in an understandable format.

I think I found a way

QListWidgetItem *wow = lwCurrentList->item ( index );
inputText = wow->text();or
inputText = lwCurrentList->item ( index ) -> text();
tsk! tsk! tsk!

Thanks.

wysota
27th January 2007, 10:08
If you have an index you can simply call index.data() to retrieve a QVariant with the data, but the snippet you have written will also work.
By the way - you could have connected to the itemDoubleClicked() signal to get the actual item right away.