[PyQt] derive from a designer widget
Mario Daniel Carugno
carugnom at gmail.com
Fri Mar 13 14:18:24 GMT 2009
2009/3/13, Andreas Pakulat <apaku at gmx.de>:
> > I want that it could be as simple as derivating the 'data' class
> > from the 'main window' class. I've read that derivating a widget
> > from another one, makes that widget to appear inside it's parent,
> > right ?
>
> No thats wrong. Deriving one class from another is something different than
> adding a widget to a parent widget.
What about this ?
#!/bin/env python
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class Frame(QDialog):
def __init__(self):
QDialog.__init__(self)
pass
class GUI(Frame):
def __init__(self):
Frame.__init__(self)
b = QLabel("HOLA")
l = QVBoxLayout()
l.addWidget(b)
self.setLayout(l)
if __name__ == "__main__":
app = QApplication(sys.argv)
ui = GUI()
ui.show()
app.exec_()
This snippet creates a Frame and a widget as a subclass of it.
This is enough to make the widget appear into the Frame
I want to achieve that, but with Frame being a compound widget with its
central area, and that area being the default 'container' to hold
derived widgets.
I note that one problem with this using designer, is that designer creates
widgets subclassing 'object' instead of 'QWidget' or 'QDialog'. With the
main form derived from 'object' i can't make the above subclassing example.
Thank you
More information about the PyQt
mailing list