[PyQt] creating a QgraphicsView in MainWindow

Mads Kofod Hansen kofoden at yahoo.com
Thu Feb 26 11:03:21 GMT 2009


Thank you both, it works now.



----- Original Message ----
From: Arnold Krille <arnold at arnoldarts.de>
To: pyqt at riverbankcomputing.com
Sent: Thursday, February 26, 2009 11:40:53 AM
Subject: Re: [PyQt] creating a QgraphicsView in MainWindow

Hi,

On Thursday 26 February 2009 11:25:25 Phil Thompson wrote:
> On Thu, 26 Feb 2009 02:16:41 -0800 (PST), Mads Kofod Hansen
> <kofoden at yahoo.com> wrote:
> > I have a QMainWindow with a menu bar and I want to create a QGraphicsView
> > below the menu bar.
> > But this only displays the MainWindow with a menubar. How do I create the
> > GraphicsView in the MainWindow?
> You aren't keeping references to your view or scene so they are being
> garbage collected.

And the easiest way to do so (if you don't need a reference for your own 
purpose) is to add the graphicsview to the mainwindow as the central widget 
done via setCentralWidget. Which has the advantage that it automaticly adds 
your graphicsview as the central widget in the mainwindow so it gets sized to 
fill all available space and get resized when the mainwindow is resized...

Have fun,

Arnold



      


More information about the PyQt mailing list