Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'Qt'
- class Imageview < Qt::GraphicsView
- def initialize(parent=nil)
- super()
- Qt::MetaObject.connectSlotsByName(self)
- end
- def loadimage(pixmap)
- @pixmap=pixmap
- end
- def resizeEvent( event)
- size=event.size
- item=Qt::GraphicsPixmapItem.new
- pixmap=@pixmap
- pixmap=Qt::Pixmap.new(@pixmap)
- pixmap.scaled(size,Qt::KeepAspectRatio, Qt::SmoothTransformation)
- item.setPixmap(pixmap)
- self.centerOn(2.0,2.0)
- #item.scale()
- # item.setTransformationMode(Qt::FastTransformation)
- # self.fitInView(item)
- end
- end
- app=Qt::Application.new(ARGV)
- #grview=Imageview.new
- pic=Qt::Pixmap.new('pic.jpg')
- grview=Imageview.new
- grview.loadimage(pic)
- scene=Qt::GraphicsScene.new
- scene.addPixmap(pic)
- grview.setScene(scene)
- #grview.fitInView(scene)
- grview.renderHint=Qt::Painter::Antialiasing | Qt::Painter::SmoothPixmapTransform
- grview.show
- app.exec
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement