[PyQt] creating a QgraphicsView in MainWindow
Mads Kofod Hansen
kofoden at yahoo.com
Thu Feb 26 10:16:41 GMT 2009
Hi all
My question is if it is possible to create a QGraphicsView in a MainWindow?
I have a QMainWindow with a menu bar and I want to create a QGraphicsView below the menu bar.
I have made a simple example:
import sys
from PyQt4 import QtGui, QtCore
class MainWindow(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.resize(250, 150)
self.setWindowTitle('menubar')
exit = QtGui.QAction(QtGui.QIcon('icons/Exit.png'), 'Exit', self)
exit.setShortcut('Ctrl+Q')
exit.setStatusTip('Exit application')
self.connect(exit, QtCore.SIGNAL('triggered()'), QtCore.SLOT('close()'))
self.statusBar()
menubar = self.menuBar()
file = menubar.addMenu('&File')
file.addAction(exit)
grview = QtGui.QGraphicsView()
scene = QtGui.QGraphicsScene()
scene.addPixmap(QtGui.QPixmap('icons/Exit.png'))
grview.setScene(scene)
app = QtGui.QApplication(sys.argv)
main = MainWindow()
main.show()
sys.exit(app.exec_())
But this only displays the MainWindow with a menubar. How do I create the GraphicsView in the MainWindow?
thanks for any help
Mads
More information about the PyQt
mailing list