DzListBox
Victor_B
Posts: 391
Hello.
I need widget like DzListBox, but with multiselection (in DzListBox I can select only 1 item).
With peace of code how to create and add items to it, please.
Or
I can use bunch of checkboxes instead, but I don't know how to wrap them into area with scrollbar (I'm limited with space). With code example, please.
Thanks.
p.s.: Daz widgets are killing me... I'm almoust dead... :)
Post edited by Victor_B on
Comments
Doesn't the selection mode cover that? http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/listbox_dz#a_1a7059dfa0ed70c89facc3d317fb4138b3
Restart docs.daz3d.com please. It's not available (Gateway Timeout) for several hours yet. Thank you.
Do you mean http://docs.daz3d.com/doku.php
Yes. It doesn't works again, btw
But I made DzListBox multi selectable.
And died... :))
And rose again to add a code to this post (maybe somebody need it)
Using the name would be more robust:
listWidget.selectionMode = DzListBox.Multi;
Were you was yesterday with this code?.... Thanks anyway. If it robust, I will use it ;)
Today I back to my dzListBox to work a little with selected Items. So, I printed out all properties and triyed to find among them something like "getItems" or "getSelectedItems" or maybe "Items" or "Selected" or...noup, nothing. There is a "selected", but it always "-1" with multiselection.
So, the question is: how to work with DzListBox? I need a loop with all items, selected items and I need to set up index to list item (idetificator), not just text label. Why, oh Heavens, insertItem(QString) has only one parameter for text label?
Ok, here is a dialog box with dzListBox. Please, add to it some code I need.
Thanks.
Ok, looks like I found a quick solution by adding
connect(listBox, "clicked(int)", getSelected);
and creating array with selected items with every click, but I don't like it. So, if you know an elegant soution - you're welcome.
Iterate through the members of the list box, for item N call oMyListBox.isSelected( N );
http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/object_index/listbox_dz#a_1a47f998baa624f9f88a2117412094c516
I know about .isSelected()
I don't know how to get members of the list box. Selected or all. That was the main question.
oMyListBox.count gives the number of items, so you just need to loop from 0 to count - 1 checking each for its selection state.
Rob offers a little example, including a neat way to cull the empty entries from an array in the last line:
Shouldn't it be:
aSelected.push( listBox.text(i) );
? Why insert into a sparse array, just to filter it out later?
Edited to fix quote
Wow, discussion... Yep, I used .count in the last version and now I see that it is the one legal method. Thanks to all. :)
About filtering... yes,
aSelected.push( listBox.text(i) );
or
aSelected[aSelected.length] = listBox.text(i);
are better imho :)
I'm just going to post rob's explanantion verbatim:
He also offers this to show the difference in timing:
A more robust performance test: