Creating a rectangular icon

Aaron J. Seigo aseigo at kde.org
Wed Mar 3 23:58:52 CET 2010


On March 3, 2010, Antony Loebs wrote:
> On Tue, Mar 2, 2010 at 9:09 PM, Aaron J. Seigo <aseigo at kde.org> wrote:
> > On March 2, 2010, Antony Loebs wrote:
> > > Ok, when I added
> > > self.layout.setPreferredWidth(120)
> > > that displays it correctly, but now it doesn't expand or contract at
> > > all horizontally. It does expand and contract vertically, however.
> > > What
> > 
> > should
> > 
> > > I add so that the height and the width of the image scale relative to
> > 
> > each
> > 
> > > other?
> > 
> > in theory, KeepAspectRatio, but in practice that's not paid attention to
> > by the panel. you'll need to keep the pixmap in ratio in your paint
> > event.
> 
> Hmm...I added the following
> def paintEvent(self, event):
>     size = self.geometry()
>     height = size.height()
>     self.resize(height * 4, height)
> 
> But that doesn't work. Do I need to completely re-implement drawing the
> pixmap in paintEvent?

yes; which isn't hard (it's one call). and you don't want to be resizing 
yourself in the paintEvent (that has the potential for endless looping due to 
resize -> repaint -> resize..)

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Qt Development Frameworks


More information about the Plasma-devel mailing list