views:

31

answers:

1

I am trying to just click on an item in a list of items in a listwidget.

I right clicked in my UI and went to the slot:

void main::listWidget_itemClicked(QListWidgetItem* item)

In there I can run commands ect... But I want the selected item that I click on to be set to a String... I tried using the CONNECT/SIGNAL route, but I came up empty there.

It would theoretically look like this: QString text = ui->listWidget->itemClicked(); obv this is wrong, but I think it expresses what i am trying to do....

How can I do this?

+3  A: 

If I get you right, you just want to set the clicked item to a new String, right?

item->setText(someQString)

Edit:

I'm not sure what you mean with "set it to a string", but you can retrieve the text (a QString) of the item with

item->text()
Sebastian N.
sort of... I want to be able to set it to a string to pass it to another function... so more like : QString text = Item_Clicked
John Studio
I have revised my original answer to include, what I think, might be the solution :)
Sebastian N.
Yes you can do item->text() with lineEdit, but not with qlistwidget, it's not an option (at least i don't think)
John Studio
Are you sure? What Qt version are you using? Could you show the code, please?
Sebastian N.
no you are right!!! sorry!
John Studio