Teermit
19th February 2013, 18:27
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");
foreach (QString imagePath, list)
{
QLabel *newItem = new QLabel(target);
newItem->setMinimumHeight(50);
newItem->setMaximumHeight(50);
newItem->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Fi xed);
QImage image(imagePath);
newItem->setPixmap(QPixmap::fromImage(image.scaledToHeight( 50)));
targetLayout->addWidget(newItem);
}
And I get this result:
8735
But I'm trying to get this result:
8736
How to make the QGridLayout create columns?
I'm trying to to add in it an image using this code:
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::Fi xed);
QImage image(imagePath);
newItem->setPixmap(QPixmap::fromImage(image.scaledToHeight( 50)));
targetLayout->addWidget(newItem);
}
And I get this result:
8735
But I'm trying to get this result:
8736
How to make the QGridLayout create columns?