[PyQt] Embedding QWidgets within a parent
c.c.wood at gmail.com
Fri Apr 25 13:23:42 BST 2014
Hmm, I've been through that tutorial several times, and I thought I was
getting the hang of stuff, but that tutorial doesn't seem to mention
anywhere anything about how to set parents or children. However, it seems
it might be easier than I thought it was - I hadn't realised that I could
do something like:
self.b = Browser()
self.grid = QtGui.QGridLayout()
def _result_available(self, ok):
frame = self.page().mainFrame()
and that Google now does appear in my gui! :) (n.b. is there a better way
to do it - should I call load() somewhere else?) but, how does the comment
about children / parents relate to this?
On 24 April 2014 20:16, Florian Bruhin <me at the-compiler.org> wrote:
> * Chris Wood <c.c.wood at gmail.com> [2014-04-24 19:29:47 +0100]:
> > If I have a standalone widget, what's the best way to integrate (/embed)
> > within a QMainWindow / parent QWidget? I know that a QScrollArea has a
> > setWidget method - but is there a better / lower level / more abstract
> > of achieving it?
> > (In my particular case, I'm using QtWebKit; using this answer (
> > http://stackoverflow.com/a/13386109/889604) as a starting point, I'd
> > to embed 'view' (which is an instance of Browser) into a parent QWidget.
> > I'd like to think that because QWebView inherits QWidget, this should be
> > easy(!))
> The answer almost seems too simple... but you're aware of the
> parent-argument of QObjects (and thus also QWidgets)?
> Basically, if you don't give a parent (wv = QWebView()), it's a
> standalone/toplevel widget, and if you do (wv = QWebView(mainwindow)),
> it's inside that widget.
> You might really want to take a look at a basic PyQt tutorial though,
> if that really was the problem. I can recommend  - even when you
> want to use PyQt5, the examples are trivial to port (just import some
> things from QtWidgets instead of QtGui usually)
>  http://zetcode.com/gui/pyqt4/
> () ascii ribbon campaign - stop html mail www.asciiribbon.org
> /\ www.the-compiler.org | I love long mails http://email.is-not-s.ms/
> Joe Cool always spends the first two weeks at college sailing his frisbee.
> PyQt mailing list PyQt at riverbankcomputing.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PyQt