I wand to scale an image on my CMS is this to much work if scale slot is a qslider
or is int width QSize and not pixel?
scaledToWidth ( int width, Qt::TransformationMode mode = Qt::FastTransformation ) const
/* header */
private:
/* header ..... */
/* i load image */
fileName = OpenFile("Image (*.png)");
if (!fileName.isEmpty()) {
connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(ModpicsChanged(int)));
...
centrale->setPixmap
(QPixmap::fromImage(image
));
...
centrale->adjustSize();
actual = centrale->pixmap()->size();
...
horizontalSlider->setSliderPosition(wi);
...
}
/* ..... */
void Gui_Image::ModpicsChanged(int newvalue_w) /* int from QSlider 20px steeps */
{
...
myPixmap = QPixmap::fromImage(image
);
myPixmap.scaledToWidth(newvalue_w,Qt::FastTransformation);
centrale->setPixmap(myPixmap); /* label */
centrale->adjustSize(); /* label */
actual = centrale->pixmap()->size();
...
}
/* header */
private:
Gui_Image( QWidget* = 0 );
QImage image;
QPixmap myPixmap;
QSize actual;
/* header ..... */
/* i load image */
fileName = OpenFile("Image (*.png)");
if (!fileName.isEmpty()) {
connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(ModpicsChanged(int)));
...
centrale->setPixmap(QPixmap::fromImage(image));
...
centrale->adjustSize();
actual = centrale->pixmap()->size();
...
horizontalSlider->setSliderPosition(wi);
...
}
/* ..... */
void Gui_Image::ModpicsChanged(int newvalue_w) /* int from QSlider 20px steeps */
{
...
myPixmap = QPixmap::fromImage(image);
myPixmap.scaledToWidth(newvalue_w,Qt::FastTransformation);
centrale->setPixmap(myPixmap); /* label */
centrale->adjustSize(); /* label */
actual = centrale->pixmap()->size();
...
}
To copy to clipboard, switch view to plain text mode
Bookmarks