hi
I would like to have a scrollarea contains a dynamic count of images...
I tried to solve it like you see below. But the problem is that the scrollbar never appear...
My approach is:
I design with the QT desinger a ScrollArea (scrollArea) with default ScrollBarAsNeeded. Then I at also in the QT Designer a widget to the ScrollArea (named scrollContent).
Then in the Programm i tried:
ScrollBoxLayout->setSpacing(2);
ScrollBoxLayout->setMargin(2);
ScrollBoxLayout->setAlignment(Qt::AlignTop);
ScrollBoxLayout
->setSizeConstraint
(QLayout::SetMinimumSize);
ui.scrollArea->setLayout(ScrollBoxLayout);
QVBoxLayout* ScrollBoxLayout = new QVBoxLayout();
ScrollBoxLayout->setSpacing(2);
ScrollBoxLayout->setMargin(2);
ScrollBoxLayout->setAlignment(Qt::AlignTop);
ScrollBoxLayout->setSizeConstraint(QLayout::SetMinimumSize);
ui.scrollArea->setLayout(ScrollBoxLayout);
To copy to clipboard, switch view to plain text mode
and add the images like:
for (it=sig.begin(); it!=sig.end(); it++){
//ignore this part
image
= QImage((uchar
*) it
->Image
()->imageData, it
->Image
()->width, it
->Image
()->height,
QImage::Format_RGB888);
image = image.rgbSwapped();
//add qlabel to widget in scrollarea
ui.scrollArea->layout()->addWidget(img);
img
->setPixmap
(QPixmap::fromImage(image
));
img->repaint();
}
for (it=sig.begin(); it!=sig.end(); it++){
//ignore this part
image = QImage((uchar *) it->Image()->imageData, it->Image()->width, it->Image()->height,QImage::Format_RGB888);
image = image.rgbSwapped();
//add qlabel to widget in scrollarea
QLabel *img = new QLabel();
ui.scrollArea->layout()->addWidget(img);
img->setPixmap(QPixmap::fromImage(image));
img->repaint();
}
To copy to clipboard, switch view to plain text mode
so the images appears like I wanted row by row... but no scrollbar appears if there are many QLabel objects added...
thx
Bookmarks