Hello. I have QGridLayout inside of QScrollArea.
I'm trying to to add in it an image using this code:
QWidget *target
= findChild<QWidget
*>
("imagesBoxContent");
QGridLayout *targetLayout
= target
->findChild<QGridLayout
*>
("gridLayout");
{
newItem->setMinimumHeight(50);
newItem->setMaximumHeight(50);
newItem
->setPixmap
(QPixmap::fromImage(image.
scaledToHeight(50)));
targetLayout->addWidget(newItem);
}
QWidget *target = findChild<QWidget*>("imagesBoxContent");
QGridLayout *targetLayout = target->findChild<QGridLayout*>("gridLayout");
foreach (QString imagePath, list)
{
QLabel *newItem = new QLabel(target);
newItem->setMinimumHeight(50);
newItem->setMaximumHeight(50);
newItem->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Fixed);
QImage image(imagePath);
newItem->setPixmap(QPixmap::fromImage(image.scaledToHeight(50)));
targetLayout->addWidget(newItem);
}
To copy to clipboard, switch view to plain text mode
And I get this result:
Снимок.PNG
But I'm trying to get this result:
Снимок_.jpg
How to make the QGridLayout create columns?
Bookmarks