Advertisement
Guest User

shadowskill

a guest
May 2nd, 2010
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.94 KB | None | 0 0
  1. require 'Qt'
  2. class Imageview < Qt::GraphicsView
  3.   def initialize(parent=nil)
  4.     super()
  5.    
  6.     Qt::MetaObject.connectSlotsByName(self)
  7.  
  8.   end
  9.   def loadimage(pixmap)
  10.     @pixmap=pixmap
  11.   end
  12.   def resizeEvent( event)
  13.     size=event.size
  14.     item=Qt::GraphicsPixmapItem.new
  15.     pixmap=@pixmap
  16.     pixmap=Qt::Pixmap.new(@pixmap)
  17.    pixmap.scaled(size,Qt::KeepAspectRatio, Qt::SmoothTransformation)
  18.    
  19.     item.setPixmap(pixmap)
  20.     self.centerOn(2.0,2.0)    
  21.     #item.scale()
  22.    # item.setTransformationMode(Qt::FastTransformation)
  23.  #   self.fitInView(item)
  24.   end
  25. end
  26. app=Qt::Application.new(ARGV)
  27. #grview=Imageview.new
  28. pic=Qt::Pixmap.new('pic.jpg')
  29. grview=Imageview.new
  30. grview.loadimage(pic)
  31. scene=Qt::GraphicsScene.new
  32. scene.addPixmap(pic)
  33. grview.setScene(scene)
  34. #grview.fitInView(scene)
  35. grview.renderHint=Qt::Painter::Antialiasing | Qt::Painter::SmoothPixmapTransform
  36. grview.show
  37. app.exec
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement