[PyQt] PyQt4 flags processing
Phil Thompson
phil at riverbankcomputing.com
Wed Sep 29 17:22:18 BST 2010
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?
> [...]
>>>> 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.
Phil
More information about the PyQt
mailing list