[Kde-java] KListViewItem problems
Maik Schulz
list at maikschulz.de
Sun Jun 6 18:55:39 CEST 2004
Hi,
while trying to populate a KListView I observed a rather odd behaviour. My
intention is to create the following structure:
PJBox
|
+- Set
+- Disc 1
+- Disc 2
Please take a look at the following code, I explain the oddities in the
comments:
listFolderTree = new KListView( splitter1, "listFolderTree" );
listFolderTree.addColumn( "Content" );
// root element "PJBox"
KListViewItem listFolderTreeItem0 = new KListViewItem( listFolderTree );
listFolderTreeItem0.setText( 0, "PJBox" );
listFolderTreeItem0.setPixmap( 0, image1 );
listFolderTreeItem0.setOpen(true);
// adding the root element worked without problems. Passing the listFolderTree
object as parent is ok here.
// level 1 element "Set"
KListViewItem listFolderTreeItem1 = new
KListViewItem(listFolderTree.firstChild());
listFolderTreeItem1.setText(0, "Set");
listFolderTreeItem1.setPixmap(0, image2);
//This _only_ works when I use the listFolderTree.firstChild() construct. It
_does not_ work when I use listFolderTreeItem0 as parent instead. Rather
inconvenient...
//level 2 element "Disc 1"
KListViewItem listFolderTreeItem2 = new
KListViewItem(listFolderTree.firstChild().firstChild());
listFolderTreeItem2.setText(0, "Disc 1");
listFolderTreeItem2.setPixmap(0, image3);
//Again, this _only_ works when I walk the tree, using listFolderTreeItem1 as
parent _does not_ work. However, note that I could successfully setText and
setPixmap on listFolderTreeItem1 in the previous step. It's a strange strange
world...
//level 2 element "Disc 2"
KListViewItem listFolderTreeItem3 = new
KListViewItem(listFolderTree.firstChild().firstChild());
listFolderTreeItem3.setText(0, "Disc 2");
listFolderTreeItem3.setPixmap(0, image3);
// According to the docs, "Disc 2" should have appeared _before_ "Disc 1"
because I did not provide "Disc 1" as the after parameter. It doesn't.
That's about it. Are these problems binding problems at all? Or are they QT
related?
Thanks,
-Maik
--
Emails accepted only from list. If you need to contact me
off list please exchange list with post in my email address.
More information about the Kde-java
mailing list