Guest User

Untitled

a guest
Nov 19th, 2013
39
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from PySide.QtGui import *
  2. from PySide.QtCore import *
  3.  
  4. class PaintTest(QScrollArea):
  5.  
  6.     def __init__( self, parent=None ):
  7.         super(PaintTest, self).__init__(parent)
  8.         self.mainWidget = QWidget()
  9.         self.setWidget(self.mainWidget)
  10.         self.setWidgetResizable( True ) # DISABLE THIS WITH ABOVE WIDGET ADDED AND THE CUSTOM PAINT EVENT IS NOT TRIGGERED
  11.  
  12.     def paintEvent( self, event ):
  13.         print 'painting'
  14.         painter = QPainter()
  15.         painter.begin( self.viewport() )
  16.         painter.drawText(self.rect(), 'test')
  17.         painter.end()
  18.  
  19.  
  20. if __name__ == '__main__':
  21.     import sys
  22.     app = QApplication([])
  23.     app.setStyle("plastique")
  24.     w = PaintTest()
  25.     w.show()
  26.     sys.exit(app.exec_())
RAW Paste Data