PDA

View Full Version : how to count total numbers items in listwidget



trupti
19th January 2011, 12:36
hello,

I have used QlisiWidget in my application.
I inserted items in it.
Now i want to count items which are inserted .

I used ui->listwidget->count() but it does not work..

Can any one help me...???




Thanks...

high_flyer
19th January 2011, 13:41
but it does not work..
What do you mean by "doesn't work"?

trupti
20th January 2011, 06:32
hello,
I mean i think it returns 0 .
how can i make it??


Thanks..

high_flyer
20th January 2011, 08:40
I mean i think it returns 0 .
You think?
Don't think - be sure!

trupti
20th January 2011, 10:25
hello,
I test it using
int i =ui->listWidget->count()
label.setText(QString(i))

And when print.It shows 0.

Is it wrong????


thanks.

tbscope
20th January 2011, 10:31
You can't use QString this way.

Instead, use QString::number(i)

Read the documentation.

trupti
21st January 2011, 08:22
hello,

Thanks for reply....

I want to show all listwidgetitems in QLabel. What i want is i set images as icon in items of listwidget. and now want to display this one by one icon image in my label..

HOw can i do it???


Thanks in advance...

Sven
21st January 2011, 12:08
You can use HTML in QLabel.

Like this:



QLabel *myCoolLabel = new QLabel();
myCoolLabel->setText("<img src=\"myFilePathOrResourceFilePath.extension\">");