maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Resizing an Image QLabel after signal requestFinished (https://talk.maemo.org/showthread.php?t=40524)

ltramon 2010-01-14 17:42

Resizing an Image QLabel after signal requestFinished
 
Hi to all!!

We are trying to load an internet image into a QLabel and we are finding some problems with the resizing of the QLabel after the connection. We will try to explain it describing our steps:

- Loading a local image into a Qlabel - OK. The QLabel resizes automatically when we load the new image into it.

- Loading an external image into a QLabel: The connection to the external url works, and we can load the image into the QLabel after the requestFinished event occurs, but we cannot resize the QLabel to the new image size. - KO.

We have tried to use the "update" method of the QLabel but this didn't work. Also, we have tried to modify the size().setWidth() and the size().setHeight but also failed.

Can anybody help us out??

Thanks in advance,

Best Regards

ltramon 2010-01-18 10:37

Re: Resizing an Image QLabel after signal requestFinished
 
Can anybody help me out, please?? .

I can't show an image , for example, into a Scroll Area.

Thanks in advance.

Sasler 2010-01-18 11:41

Re: Resizing an Image QLabel after signal requestFinished
 
Quote:

Originally Posted by ltramon (Post 471490)
Hi to all!!

We are trying to load an internet image into a QLabel and we are finding some problems with the resizing of the QLabel after the connection. We will try to explain it describing our steps:

- Loading a local image into a Qlabel - OK. The QLabel resizes automatically when we load the new image into it.

- Loading an external image into a QLabel: The connection to the external url works, and we can load the image into the QLabel after the requestFinished event occurs, but we cannot resize the QLabel to the new image size. - KO.

We have tried to use the "update" method of the QLabel but this didn't work. Also, we have tried to modify the size().setWidth() and the size().setHeight but also failed.

Can anybody help us out??

Thanks in advance,

Best Regards

Not really a solution, but more like a workaround: Why don't you try to first load the external image to a file and then load that local image to the QLabel?

krk969 2010-01-18 11:45

Re: Resizing an Image QLabel after signal requestFinished
 
Quote:

Originally Posted by ltramon (Post 471490)
....

We have tried to use the "update" method of the QLabel but this didn't work. Also, we have tried to modify the size().setWidth() and the size().setHeight but also failed.

Can anybody help us out??

Best Regards

get the pixmap of the imageLabel ( QLabel loaded with a QImage pixmap), and do

imageLabel->resize(scale * imageLabel->pixmap()->size());

see if it works :)

ltramon 2010-01-18 13:19

Re: Resizing an Image QLabel after signal requestFinished
 
Quote:

Originally Posted by krk969 (Post 479650)
get the pixmap of the imageLabel ( QLabel loaded with a QImage pixmap), and do

imageLabel->resize(scale * imageLabel->pixmap()->size());

see if it works :)

It doesn´t work too :(


This code works fine and it shows all widgets:

QGridLayout *optionsLayout = new QGridLayout;
int x=0;

QLabel *lastModLabel = new QLabel("Hello");

optionsLayout->addWidget(lastModLabel, x,0);
optionsLayout->addWidget(new QLabel("Tag 1"), x, 1);
optionsLayout->addWidget(new QLineEdit("QLineEdit"), x, 2);
optionsLayout->addWidget(new QPushButton("QPushButton"), x, 3);
optionsLayout->addWidget(new QCheckBox("QCheckBox"), x, 4);
optionsLayout->addWidget(new QComboBox(), x, 5);
optionsLayout->addWidget(new QCalendarWidget(), x, 6);
optionsLayout->addWidget(new QCommandLinkButton(), x, 7);
optionsLayout->addWidget(new QDial(), x, 8);
optionsLayout->addWidget(new QDoubleSpinBox(), x, 9);

ui->scrollAreaWidgetContents->setLayout(optionsLayout);



But if I do:

QImage img("1.jpg");
QLabel *lastModLabel = new QLabel("");
lastModLabel->setPixmap(QPixmap::fromImage(img));
lastModLabel->resize(1 * lastModLabel->pixmap()->size());

optionsLayout->addWidget(lastModLabel, x,0);

ui->scrollAreaWidgetContents->setLayout(optionsLayout);


The Image doesn't appear into the Scroll Area. Why?.

What is it happening?.


All times are GMT. The time now is 19:16.

vBulletin® Version 3.8.8