Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, December 2006
QComboBox does not display new data


Message 1 in thread

Hi,

As I understand a combobox that you attach a model (setModel) to is 
supposed to update automatically, when the underlying data change. This 
works fine, until you show the popup menu of the combobox. If you then 
manipulate your model and show the popup menu again the new added data 
are blank and non-selectable, even though they appear to be "visible" in 
some way to the combobox.

Can you please look at the sample code I attach and tell me what I have 
missed out? (note that showing the popup interactively with the mouse or 
programmatically as I have done it on this example triggers the same 
behavior)

thanks.

--stathis

Attachment:

Attachment: combotest.zip
Description: Zip compressed data


Message 2 in thread

Wednesday 06 December 2006 15:20 skrev Stathis:
> Hi,
>
> As I understand a combobox that you attach a model (setModel) to is
> supposed to update automatically, when the underlying data change. This
> works fine, until you show the popup menu of the combobox. If you then
> manipulate your model and show the popup menu again the new added data
> are blank and non-selectable, even though they appear to be "visible" in
> some way to the combobox.
>
> Can you please look at the sample code I attach and tell me what I have
> missed out? (note that showing the popup interactively with the mouse or
> programmatically as I have done it on this example triggers the same
> behavior)

You need to use the beginInsertRows and endInsertRows methods. Right now you 
don't tell the list that it's changed - how would it know that?

Bo.

-- 
 [ signature omitted ] 

Message 3 in thread

Bo Thorsen wrote:
> Wednesday 06 December 2006 15:20 skrev Stathis:
>> Hi,
>>
>> As I understand a combobox that you attach a model (setModel) to is
>> supposed to update automatically, when the underlying data change. This
>> works fine, until you show the popup menu of the combobox. If you then
>> manipulate your model and show the popup menu again the new added data
>> are blank and non-selectable, even though they appear to be "visible" in
>> some way to the combobox.
>>
>> Can you please look at the sample code I attach and tell me what I have
>> missed out? (note that showing the popup interactively with the mouse or
>> programmatically as I have done it on this example triggers the same
>> behavior)
> 
> You need to use the beginInsertRows and endInsertRows methods. Right now you 
> don't tell the list that it's changed - how would it know that?
> 
> Bo.
> 

In the example I sent, if you remove the lines:

b.showPopup ();
b.hidePopup ();

then how does it then know? The data have changed after the model was 
attached?

Since querying rowCount() effectively retrieves the size from the 
internal data structure, it would be expectable that the combobox 
dynamically resizes and requests from the data() method the appropriate 
data for each index, but this does not happen, the empty entries are 
added but you cannot select them (the data() is never called for them).

The call to insertRows() would also mean that I cannot internally resize 
my dataset, that is if Box procedurally generates items to itself, or 
someone else adds them to it (no model/view style), the views even 
though have all the facilities to find out that there is new data, when 
the popup is displayed, they won't.

Maybe what i want to do cannot be done this way? As far as I see it, 
this is unexpected behavior, because if the view is totally unaware of 
changes on the underlying datastructure, then it should not add empty 
entries to the combobox.

--stathis

Attachment:

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature