[PyKDE] QListbox: SetColumnMode(int)

Phil Thompson phil at riverbankcomputing.co.uk
Wed Jun 30 14:59:01 BST 2004


On Wednesday 30 June 2004 12:30 pm, Sibylle Koczian wrote:
> Hello,
>
> this doesn't seem to work as it should. In the example "listbox.py" (part
> of the PyQt-package) the first radio button should set the listbox to a
> fixed number of columns, as given in the spinbox below. But it doesn't, the
> listbox doesn't react at all. The same for the radio button that should set
> the box to a fixed number of rows: SetRowMode(int) doesn't seem to work
> either. I didn't change anything in the example. The two other radio
> buttons work as expected: set the number of columns (or of rows) to the
> maximal number visible in the listbox and change the number of rows (or of
> columns) accordingly.
>
>  From the Qt documentation I see that there are two overloaded methods
> SetColumnMode and SetRowMode:
> SetColumnMode(int), SetColumnMode(LayoutMode), and LayoutMode is an
> enumeration type. I don't know how that translates to Python, and I suspect
> the problem might lie here.

You analysis is exactly right. SIP uses integers to implement enums and so 
cannot distinguish between to two setColumnMode() signatures.

> Using PyQt 3.12, sip 4.0, Python 2.3.3 on SuSE Linux 9.1.
>
> How can I set the number of columns in a listbox to a fixed value greater
> than 1?

I don't think you can without modifying PyQt. You would need to edit 
qlistbox.sip and change...

	virtual void setColumnMode(int);

...to something like...

	virtual void setColumnMode(int) /PyName=setNrColumns/;

...and for setRowMode() as well.

I will fix this properly for SIP 4.1 and implement enums as a different type.

Phil




More information about the PyQt mailing list