[PyQt] QGraphicsView Full Screen
Tim and Alison Bentley
Home at TRARBentley.net
Mon Dec 28 19:23:07 GMT 2009
I have trying to create an application where the QGraphicsScene and View are
full screen.
I can make an Qwidget full screen and get it's size but I am unable to get
the
QGraphicsview to become full screen. The best I have managed is 3/4 size.
My latest example code is here:
import sys
from PyQt4 import QtCore, QtGui, QtOpenGL
app = QtGui.QApplication(sys.argv)
test = QtGui.QWidget()
test.showFullScreen()
scene = QtGui.QGraphicsScene()
#scene.setBackgroundBrush(QtGui.QBrush(QtCore.Qt.blue))
#scene.setBackgroundBrush(QtGui.QBrush(QtCore.Qt.transparent))
#view1 = scene.addText("Hello, world!", QtGui.QFont("Times", 10,
QtGui.QFont.Bold));
item1 = QtGui.QGraphicsPixmapItem()
item1.setPixmap(QtGui.QPixmap("<<Image file goes here>>>"))
scene.addItem(item1)
item2 = QtGui.QGraphicsTextItem()
item2.setFont(QtGui.QFont("Times", 50, QtGui.QFont.Bold))
item2.setPlainText("Hello, world!")#, ;
scene.addItem(item2)
view = QtGui.QGraphicsView(scene, test)
view.setBackgroundBrush(QtGui.QBrush(QtCore.Qt.transparent))
view.setRenderHint(QtGui.QPainter.Antialiasing &
QtGui.QPainter.SmoothPixmapTransform)
view.setSceneRect(QtCore.QRectF(QtCore.QPointF(0, 0), QtCore.QSizeF(1280,
1024)))
print view.maximumViewportSize()
print scene.sceneRect()
print view.sceneRect()
print view.isFullScreen()
view.setViewport(QtOpenGL.QGLWidget())
#view.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
#view.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
view.setViewportUpdateMode(QtGui.QGraphicsView.FullViewportUpdate)
view.setFrameStyle(0);
view.showFullScreen()
print view.isFullScreen()
sys.exit(app.exec_())
Also does anyone know why the *view.setSceneRect *is required to see the
TextItem over the image.
Many Thanks
--
Tim and Alison Bentley
Home at TRARBentley.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20091228/1256a03a/attachment.html
More information about the PyQt
mailing list