Guest User

Untitled

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