problem with "QListWidget" item
I have a QListWidget "lwlistData" and I want the text of the third item in the list . (n = 3);
I assume I should use
Quote:
QListWidgetItem * QListWidget::item ( int row ) const
Returns the item that occupies the given row in the list if one has been set; otherwise returns 0.
when I use
Code:
QString t
= lwDataList
->item
(n
- 1);
I get
Quote:
dlgmain.cpp:1067: error: invalid conversion from 'QListWidgetItem*' to 'char'
dlgmain.cpp:1067: error: initializing argument 1 of 'QString& QString::operator=(char)'
Please show what the command should be.
I have been using Qt3 and now Ot4 since it came out and I still have MAJOR trouble deciphering this stuff. I go to "more" and there is all kind of help for inserting items, but none that I can find on getting an item.
If for each command there was a simple example of it's use as there is on some of the commands, it would be wonderful for "stupid" people like me.
Thanks
Re: problem with "QListWidget" item
The docs say it all - just make sure you read correctly ;)
Quote:
QListWidgetItem * QListWidget::item ( int row ) const
Quote:
1.
QString t = lwDataList->item(n - 1);
got it? ;)
try
Code:
QString t
= lwDataList
->item
(n
- 1)->text
();
Re: problem with "QListWidget" item
Code:
QString t
= lwDataList
->item
(n
- 1)->text
();
Re: problem with "QListWidget" item
damnit, these two beat me to it :P
Re: problem with "QListWidget" item
Use QListWidgetItem::text() to get the text of the item:
Code:
QString t
= lwDataList
->item
(n
- 1)->text
();
// or more in a more safe way
if (item) t = item->text();
Edit: Damn, I'm slow today :p
Re: problem with "QListWidget" item
Ok, give us our thanks now...
:)
Re: problem with "QListWidget" item
Quote:
Originally Posted by
marcel
Ok, give us our thanks now...
:)
I certainly to