[PySide] QLabel crops pixmap

Frank Rueter | OHUfx frank at ohufx.com
Mon Mar 14 20:51:45 CET 2016


Nobody?
Guess I will use pngs then until I can figure this out.

On 14/03/16 3:36 pm, Frank Rueter | OHUfx wrote:
> Hi all,
>
> so I have realised that its not the QLabel but the QPixmap in 
> combination to a vector graphic (svg).
> Below is my test code which works fine on osx but crops the image on 
> the right hand side when run under windows.
> The svg was saved with a 200 pixel output resolution in the header, 
> and when I check the QPixmap's width it does return 200, still it 
> crops the image.
> Do I actually have to start using Qt.QSvgRender for something simple 
> like this?
>
> Cheers,
> frank
>
>
> from PySide import QtGui
> def pixmapTest(imgPath):
>     l = QtGui.QLabel()
>     l.setPixmap(QtGui.QPixmap(imgPath))
>     return l
>
> if __name__ == '__main__':
>     import sys
>     app = QtGui.QApplication([])
>     if sys.platform == 'win32':
>         imgPath = 'z:/path/to/svg/image.svg'
>     else:
>         imgPath = '/server/path/path/to/svg/image.svg'
>     l = pixmapTest(imgPath)
>     l.show()
>     sys.exit(app.exec_())
>
> On 11/03/16 7:46 pm, Frank Rueter | OHUfx wrote:
>>
>> Hi,
>>
>> I have been using something like the below code on osx without 
>> trouble (simple QLabel with setPixmap to show an svg file from my 
>> resource module).
>>
>> When running the same code on windows, the label crops the image on 
>> the right, and I cannot figure out how to make it behave the same as 
>> under osx (adjust to the pixmap's size). Even brudte forcing it's 
>> width to somethign much larger than the pixmap will still result in a 
>> cropped display.
>>
>> Does anybody know what might be going on?
>>
>> Cheers, frank
>>
>> import common
>>
>> from PySide.QtGui import * # for testing only
>>
>> from PySide.QtCore import * # for testing only
>>
>> class TestImageLabel(QLabel):
>>
>> def __init__(self, parent=None):
>>
>> super(TestImageLabel, self).__init__(parent)
>>
>> self.pm = common.IconCache.getPixmap('nuBridge_logo')
>>
>> self.setPixmap(self.pm)
>>
>> def showEvent(self, e):
>>
>> super(TestImageLabel, self).showEvent(e)
>>
>> print self.pm.width()
>>
>> print self.width()
>>
>> w = TestImageLabel()
>>
>> w.show()
>>
>> -- 
>> ohufxLogo 50x50 <http://www.ohufx.com> 	*vfx compositing 
>> <http://ohufx.com/index.php/vfx-compositing> | *workflow 
>> customisation and consulting 
>> <http://ohufx.com/index.php/vfx-customising>* *
>>
>>
>>
>> _______________________________________________
>> PySide mailing list
>> PySide at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/pyside
>
> -- 
> ohufxLogo 50x50 <http://www.ohufx.com> 	*vfx compositing 
> <http://ohufx.com/index.php/vfx-compositing> | *workflow customisation 
> and consulting <http://ohufx.com/index.php/vfx-customising>* *
>
>
>
> _______________________________________________
> PySide mailing list
> PySide at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/pyside

-- 
ohufxLogo 50x50 <http://www.ohufx.com> 	*vfx compositing 
<http://ohufx.com/index.php/vfx-compositing> | *workflow customisation 
and consulting <http://ohufx.com/index.php/vfx-customising>* *

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20160315/ff05e3ed/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 2666 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20160315/ff05e3ed/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 2666 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20160315/ff05e3ed/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ohufxLogo_50x50.png
Type: image/png
Size: 2666 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20160315/ff05e3ed/attachment-0002.png>


More information about the PySide mailing list