[PyQt] Re: Zoom or scale into an QImage

Phil Thompson phil at riverbankcomputing.com
Wed Feb 11 13:18:19 GMT 2009


On Wed, 11 Feb 2009 14:12:57 +0100, Markus Feldmann
<feldmann_markus at gmx.de> wrote:
> At this moment i am trying the example:
> http://doc.trolltech.com/4.4/widgets-imageviewer.html
> 
> But i have trouble to convert the class-method <scaleImage()>.
> 
> There is a Qt Method which is not listed in the Qt API
> Library. It is named <Q_ASSERT>.

http://doc.trolltech.com/4.4/qtglobal.html#Q_ASSERT

> How should my PyQt4 Code looks like for this Class-Method?
> I doesn't know what i have to do with <Q_ASSERT>.
> 
> Here i post the part of the example:
> ################################################################
>   void ImageViewer::scaleImage(double factor)
>   {
>       Q_ASSERT(imageLabel->pixmap());
>       scaleFactor *= factor;
>       imageLabel->resize(scaleFactor * imageLabel->pixmap()->size());
> 
>       adjustScrollBar(scrollArea->horizontalScrollBar(), factor);
>       adjustScrollBar(scrollArea->verticalScrollBar(), factor);
> 
>       zoomInAct->setEnabled(scaleFactor < 3.0);
>       zoomOutAct->setEnabled(scaleFactor > 0.333);
>   }

The equivalent Python is...

    assert self.imageLabel.pixmap() is not None

Phil


More information about the PyQt mailing list