PDA

View Full Version : directly passing text() trough slot from QListWidgetItem



joval
28th July 2012, 16:27
Hi

I have something like:

connect( list, SIGNAL( itemDoubleClicked( QListWidgetItem* ) ), this, SLOT( slotFromListWidget( QListWidgetItem* ) ) );and then in slotFromListWidget function we do some things with item->text(). Is there any way to directly pass the text() return value?
I mean something like

connect( list, SIGNAL( itemDoubleClicked( QListWidgetItem* ) ), this, SLOT( slotFromListWidget( (QListWidgetItem*).text() ) ) ); while the slot will be
slotFromListWidget(QString str) but such things don't work.

Thanks in advance.

amleto
28th July 2012, 16:49
You can either subclass the list widget and add another signal

void
mylistclass::myslotfordoubleclick(QListWidgetItem* item)
{
emit mynewstringsignal(item->text());
}
or just connect the signal with the widgetitem to your other class, making sure the slot signature is correct. But you cannot do anything like you ask in your op.

joval
28th July 2012, 17:59
You can either subclass the list widget and add another signalThat's what I have already done, just wondering if I can 'condense' it in some way.


or just connect the signal with the widgetitem to your other class, making sure the slot signature is correctCould you show some example? I don't know what you mean.

Thanks for response.

amleto
28th July 2012, 18:12
I mean this:



I have something like:

connect( list, SIGNAL( itemDoubleClicked( QListWidgetItem* ) ), this, SLOT( slotFromListWidget( QListWidgetItem* ) ) );and then in slotFromListWidget function we do some things with item->text()