Unable to display items of QListWidget
Hi…
I have a problem in displaying the QListWidget ..
When i have create the QListWidget from the drag and drop menu..and used like this
- ui->listWidget->addItem("Hello")
,its working fyn and displaying int the form when i execute.
But if i do the same in this manner,
- ui->listWidgetItem->addItem(q1);
The above code compiles with no errors,but in the list widget i am unable to find the item.
Does anyone please sort out this problem..
Thanks in advance….
edit: Code highlighting / Vass
10 replies
I think this should look something like this:
And, according to the documentation, this will add the item to the list too, so it is not required to call the addItem.
If you have a sorted list, the above line has an undeterministic behaviour. In this case set the second paramater (parent) of the constructor to 0 and use ui->listWidget->insertItem(…) to insert the new item.
You must log in to post a reply. Not a member yet? Register here!




