Reply
Thread Tools
Posts: 5 | Thanked: 0 times | Joined on Jan 2010 @ Madrid - Spain
#1
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
 
Posts: 5 | Thanked: 0 times | Joined on Jan 2010 @ Madrid - Spain
#2
Can anybody help me out, please?? .

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

Thanks in advance.
 
Posts: 434 | Thanked: 325 times | Joined on Sep 2009
#3
Originally Posted by ltramon View Post
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's Avatar
Posts: 754 | Thanked: 630 times | Joined on Sep 2009 @ London
#4
Originally Posted by ltramon View Post
....

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
 
Posts: 5 | Thanked: 0 times | Joined on Jan 2010 @ Madrid - Spain
#5
Originally Posted by krk969 View Post
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?.
 
Reply


 
Forum Jump


All times are GMT. The time now is 20:43.