PDA

View Full Version : qlistwidget shows only one item



szisziszilvi
18th August 2011, 12:20
Hi,

my problem is that I have a QListWidget on my gui and it cannot show more than one item. What have I ticked/set accidentally?! It worked before just fine! Now I'm trying to fill it simply from the Mainindow's contructor like this:


ui->listWidget_meta->addItem("one");
ui->listWidget_meta->addItem("two");


and the result is that I can't see "one", only "two" - as on the attached image. No matter how many items I add, always the last one is there.

What's more I cannot click on the item. It is not enabled (as you can see it is not grey), but simply unchoseable.

jacks916
18th August 2011, 13:54
I went with the QListWidgetItem options just because i found using Items was easier for my application.

I would go this route or using QStringList, just depends on your requirements.



QListWidget _list;
QListWidgetItem *i = new QListWidgetItem( "one");
_list->addItem( i );
QListWidgetItem *j = new QListWidgetItem( "two");
_list->addItem( j );


Other things you could do is use currentRow() to see if it is incrementing correctly

szisziszilvi
19th August 2011, 09:52
currentRow() returns with the value of -1. This must be because nothing is selected. However as I mentioned before nothing _can_ be selected and I cannot see why.
I also tried the QListWidget::count() function and it returned with the proper number of the added items. Now where are the rest? I still see only one, the last one, no matter how many I add.