[Qt-interest] Populating a QListView from a QComboBox

Freddie Witherden freddie at witherden.org
Tue May 5 12:57:57 CEST 2009


Hi all,

In my application I have a QGraphicsView consisting of  
DoublePendulumItem's (: public QObject, public QGraphicsItem). These  
are configured and stored using a combo box. The items are associated  
with the combo box by using ->setData with DoublePendulumItem* being  
declared as a metatype.

In another part of my application I need to allow the user to select  
specific DoublePendulumItem (check and un-check them) as well as re- 
order them. To do this I tried using the combo boxes model() as the  
model for a QListView. However, I am facing several problems:

1) The list view works on the model directly; ideally I want it to  
work on a copy. However, models are QObjects and so not suitable for  
copying. (The DoublePendulumItems* do not need to be duplicated, just  
the model). What is the best way to do this?

2) When I do populate the QListView using the combo boxes model I run  
into the problem that when I attempt to move an item (internal drag- 
and-drop) I get: QVariant::save unable to save type 258 and  
QVarient::load unable to load type 258. Google turns up a blank on  
this one, what does one need to do to fix this?

3) I am not exactly sure how to enable checking for items. I found an  
example for Qt 3.3 and an ML post on it (http://lists.trolltech.com/qt-interest/2005-08/msg00516.html 
) and from what I can gather I will need to subclass  
QAbstractItemModel. However, does anyone have any Qt 4 examples of this?

Regards, Freddie.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090505/cf8cdcf0/attachment.bin 


More information about the Qt-interest-old mailing list