Derek Fountain wrote:
> I've been getting started with the documented example for the C++ version of 
> Qt as integrated into Eclipse. I know C++, but am working in Java, converting 
> the example code as I go. I come to this:
> 
>   if (!name.isEmpty() && !email.isEmpty()) {
>     QListWidgetItem *item = new QListWidgetItem(name, ui.addressList);
>     item->setData(Qt::UserRole, email);
>     ui.addressList->setCurrentItem(item);
>   }
> 
> 
> It's that setData() method that's puzzling me. My interpretation is that the 
> list item, as well as having the string that it appears in the list with, can 
> also have an attached piece of data. In this case it's being used to hold the 
> email address.
> 
> Assuming that's right, or even if it isn't, what's the QtJambi equivalent of 
> setdata()? It doesn't seem to have that method or anything similar.

Your interpretation is correct. Internally the item stores multiple 
entries. It contains, pixmaps, fonts, strings, colors and also user data.

There is a setData():

http://doc.trolltech.com/qtjambi-4.4/html/com/trolltech/qt/gui/QListWidgetItem.html#setData(int,%20java.lang.Object)

You specify the role as an integer (values in 
com.trolltech.qt.core.Qt.ItemDataRole) and the object to store.

best regards,
Gunnar
_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest

Reply via email to