python - PyQt4: Graphics View and Pixmap Size -


i'm developing gui using qtdesigner image processing tasks. have 2 graphic views beneath each other in grid layout. both should display image , later on add overlays.

i create pixmap img_pixmap , add scene. scene added graphics view. since image larger screen size apply fitinview(). in code:

self.img_pixmap_p =  self.img_scene.addpixmap(img_pixmap) self.img_view.setscene(self.img_scene) self.img_scene.setscenerect(qtcore.qrectf()) self.img_view.fitinview(self.img_scene.scenerect(), qtcore.qt.keepaspectratio) 

so far, how rid of white space around image view? ideally, want pixmap use full width of graphics view , keep aspect ratio, graphics view should adjust height accordingly. ideas on how achieve in straight forward fashion?

here image better idea of get:

nobody likes white borders

as can see, there white borders, want avoid.

okay, did suggested pavel:

img_aspect_ratio =  float(pixmap.size().width()) / pixmap.size().height()  width = img_view.size().width() img_view.setfixedheight( width / img_aspect_ratio ) img_view.fitinview(img_scene.scenerect(), qtcore.qt.keepaspectratio) 

it works fine when call in each resizeevent().


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -