[PyQt] PyQt4 flags processing
Hans-Peter Jansen
hpj at urpla.net
Wed Sep 29 19:27:37 BST 2010
On Wednesday 29 September 2010, 18:22:18 Phil Thompson wrote:
> On Wed, 29 Sep 2010 11:11:41 +0200, "Hans-Peter Jansen" <hpj at urpla.net>
>
> wrote:
> > Hi Phil,
> >
> > I believe, that code like this ought to run correctly:
> >
> > from PyQt4 import QtCore, QtGui
> >
> > class Widget(QtGui.QWidget):
> > def __init__(self, parent = None, flags = 0):
> > super(Widget, self).__init__(parent, flags)
> >
> > app = QtGui.QApplication([])
> > win = Widget()
> > win.show()
> > app.exec_()
> >
> > Now it results in:
>
> When you say "now" do you mean it used to behave differently?
Yes, IIRC. I have code like this from sip3/PyQt3 times:
class Plotter(QWidget):
def __init__(self, parent = None, name = "", flags = 0):
QWidget.__init__(self, parent, name, flags | Qt.WNoAutoErase)
that ought to have worked..
> > [...]
> >
> >>>> win = Widget()
> >
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in <module>
> > File "<stdin>", line 3, in __init__
> > TypeError: QWidget(QWidget parent=None, Qt.WindowFlags flags=0):
> > argument 2 has unexpected type 'int'
> >
> > Do we really need wrap the flags argument with
> > QtCore.Qt.WindowFlags(flags) to make this work correctly?
>
> All you need to do is...
>
> def __init__(self, parent=None, flags=QtCore.Qt.WindowFlags(0)):
>
> ...which seems reasonable to me.
I feared, you would say that ;-).
Sure, but it feels arkward, doesn't it? (Apart from being loquacious _and_
painful for users, that were indulged from C++ (which is a contradiction in
itself)).
Pete
More information about the PyQt
mailing list