D
D
danis_20142017-02-02 00:09:43
Python
danis_2014, 2017-02-02 00:09:43

How to fit an image to a widget?

You need to do something like a VK tape. But it turns out that some images simply do not fit into the feed:
dd53e1d50e25427ebe906d4b0db1863a.jpg
How can you fit images to the size of the feed, or how can you resize a photo at all?
Solved:
QPixmap class has scaled(x, y) method to resize images

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2017-02-13
@danis_2014

Here is the solution:

self.button = QPushButton(self)
self.button.setIconSize(QSize(50,50))
self.button.setGeometry(0,0, 40,40)
self.button.setIcon(QIcon(QPixmap("button_run.png")))

self.button.setIconSize(QSize(50,50))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question