PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 66 - error when setting QToolButton.setToolButtonStyle
: error when setting QToolButton.setToolButtonStyle
Status: CLOSED WONTFIX
Product: PySide
Classification: Unclassified
Component: QtGui
: 0.2.0
: PC Linux
: P5 normal
Assigned To: renato filho
:
:
:
  Show dependency treegraph
 
Reported: 2009-09-17 12:01 EEST by Paolo
Modified: 2009-10-22 09:15 EEST (History)
5 users (show)

See Also:


Attachments
this script reproduces the bug (1.31 KB, text/x-python)
2009-09-17 12:01 EEST, Paolo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paolo 2009-09-17 12:01:24 EEST
Created attachment 17 [details]
this script reproduces the bug

There is an error with QToolButton.setToolButtonStyle


~$ ./pyside.py
Traceback (most recent call last):
  File "./pyside.py", line 48, in <module>
    dialog = Test()
  File "./pyside.py", line 21, in __init__
    self.changeTB(1)
  File "./pyside.py", line 35, in changeTB
    tb.setToolButtonStyle(n - 1)
Boost.Python.ArgumentError: Python argument types in
    QToolButton.setToolButtonStyle(QToolButton, int)
did not match C++ signature:
    setToolButtonStyle(QToolButton {lvalue}, Qt::ToolButtonStyle)


In attachment there is my script that works on pyqt4, but it fails on pyside.


my system: ubuntu 9.04 on amd64, pyside 0.2.1 (your ppa repos)
Comment 1 Luciano Wolf 2009-09-23 19:05:41 EEST
This PyQt4 behaviour is not appropriate. An enum should use its own values
instead of integer ones to avoid invalid entries (like values out of range) or
other kind of mistakes. It's like converting longs to integers. Sometimes it
does work but one day you will get in trouble.
Comment 2 Anderson Lizardo 2009-10-22 09:15:36 EEST
I know this is marked como WONTFIX, but there's an interesting feature in the
GObject based bindings that we could implement for these cases (if not already
there):

Have the enum types as classes with a constructor that takes a integer. This
constructor would take the integer, and based on it, return the corresponding
enum object. If the enum is out of range, it generates an exception.

For instance, suppose you have in C:

// module "foo"

typedef enum {
    FOO, // 0
    BAR, // 1
    BAZ, // 2
} MyEnum;

class Foo {
    void someMethod(MyEnum x);
};

Currently the generator would only accept (I suppose, from the bug report):

import foo
f = foo.Foo()
f.someMethod(foo.MyEnum.BAZ)

My proposal would involve allowing to have:

import foo
f = foo.Foo()
f.someMethod(foo.MyEnum(2))

Here, "foo.MyEnum(2)" would return exactly foo.MyEnum.BAZ. If someone calls
e.g. "foo.MyEnum(3)", an appropriate exception would be generated.

There are some cases where allowing methods which take enums to also accept
integers, e.g. when you are doing some de-serialization and you have only the
integer value for the enum.