[Kde-bindings] puic QListView code generation problem
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Mon Sep 1 09:15:19 UTC 2003
I've just been updating the rbuic for the Qt 3.2 style of uic code generation
- it generates a 'languageChanged()' slot where all the text items of the
widgets are set up. When the puic is updated, it might help to do a patch of
rbuic before and after to see what's changed. It was really fiddly using Kate
with the split view going through the uic and rbuic sources visually
inspecting what had changed.
While I was doing that, I noticed a subtle problem in the puic code generation
for the QListView in the widgetsbase.ui example used in the Qt demo.
In puic/PerlQt, the listview looks like this:
Things Text Comment
Airbrush icon Arrow icon Standard paint tool
Eraser icon Arrow icon Standard paint tool
Local
Draft #1
Inbox 143 messages (5 new)
Whereas the C++ version looks like this:
Things Text Comment
Airbrush icon Arrow icon Standard paint tool
Inbox 143 messages (5 new)
Local
Draft #1
Server
Eraser icon Arrow icon Standard paint tool
Here is the PerlQt code generated:
my $item = Qt::ListViewItem(ListView3, undef);
$item->setText(0, trUtf8("Airbrush"));
$item->setPixmap(0, $image35);
$item->setPixmap(1, $image36);
$item->setText(2, trUtf8("Standard paint tool"));
my $item = Qt::ListViewItem(ListView3, $item);
$item->setPixmap(0, $image37);
$item->setText(1, trUtf8("Eraser"));
$item->setPixmap(1, $image36);
$item->setText(2, trUtf8("Standard paint tool"));
my $item = Qt::ListViewItem(ListView3, $item);
$item->setOpen(1);
my $item_2 = Qt::ListViewItem($item, $item);
$item_2->setOpen(1);
my $item = Qt::ListViewItem($item_2, $item);
$item->setText(0, trUtf8("Draft #1"));
$item->setPixmap(0, $image39);
$item_2->setText(0, trUtf8("Local"));
$item->setOpen(1);
my $item = Qt::ListViewItem($item, $item_2);
$item->setText(0, trUtf8("Server"));
$item->setText(0, trUtf8("Inbox"));
$item->setPixmap(0, $image38);
$item->setText(1, trUtf8("143 messages"));
$item->setText(2, trUtf8("(5 new)"));
Each time it creates a new ListViewItem under ListView3, it adds it after
'$item'. This is the C++ version, which looks pretty similar, so I assume the
problem is related to declaring 'my $item' several times.
QListViewItem * item = new QListViewItem( ListView3, 0 );
item->setText( 0, tr( "Airbrush" ) );
item->setPixmap( 0, image35 );
item->setPixmap( 1, image36 );
item->setText( 2, tr( "Standard paint tool" ) );
item = new QListViewItem( ListView3, item );
item->setPixmap( 0, image37 );
item->setText( 1, tr( "Eraser" ) );
item->setPixmap( 1, image36 );
item->setText( 2, tr( "Standard paint tool" ) );
QListViewItem * item_2 = new QListViewItem( ListView3, item );
item_2->setOpen( TRUE );
QListViewItem * item_3 = new QListViewItem( item_2, item );
item_3->setOpen( TRUE );
item = new QListViewItem( item_3, item );
item->setText( 0, tr( "Draft #1" ) );
item->setPixmap( 0, image39 );
item_3->setText( 0, tr( "Local" ) );
item_2->setOpen( TRUE );
item = new QListViewItem( item_2, item_3 );
item->setText( 0, tr( "Server" ) );
item_2->setText( 0, tr( "Inbox" ) );
item_2->setPixmap( 0, image38 );
item_2->setText( 1, tr( "143 messages" ) );
item_2->setText( 2, tr( "(5 new)" ) );
-- Richard
PS: Apologies for incoherent drunk Saturday night postings on the kde-perl
list, and perl cluelessness - I've banned myself now! No ruby on kde-perl,
only here on kdebindings, as it confuses everyone (and even when I'm sober
maybe :) ).
More information about the Kde-bindings
mailing list