[Kde-java] KListViewItem problems

Richard Dale Richard_Dale at tipitina.demon.co.uk
Sun Jun 6 20:28:47 CEST 2004


On Sunday 06 June 2004 17:55, Maik Schulz wrote:
> 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?
Please can you post full example code with suitable test cases so this can be 
run and tried out? The example above is much too complex to just read the 
source and 'think about it'.

But I would be surprised if the java bindings managed to change the semantics 
of KListViewItem insertion into a KListView.

-- Richard


More information about the Kde-java mailing list