rouge
13th May 2011, 12:58
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:
QVBoxLayout* ScrollBoxLayout = new QVBoxLayout();
ScrollBoxLayout->setSpacing(2);
ScrollBoxLayout->setMargin(2);
ScrollBoxLayout->setAlignment(Qt::AlignTop);
ScrollBoxLayout->setSizeConstraint(QLayout::SetMinimumSize);
ui.scrollArea->setLayout(ScrollBoxLayout);
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
QLabel *img = new QLabel();
ui.scrollArea->layout()->addWidget(img);
img->setPixmap(QPixmap::fromImage(image));
img->repaint();
}
so the images appears like I wanted row by row... but no scrollbar appears if there are many QLabel objects added...
thx
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:
QVBoxLayout* ScrollBoxLayout = new QVBoxLayout();
ScrollBoxLayout->setSpacing(2);
ScrollBoxLayout->setMargin(2);
ScrollBoxLayout->setAlignment(Qt::AlignTop);
ScrollBoxLayout->setSizeConstraint(QLayout::SetMinimumSize);
ui.scrollArea->setLayout(ScrollBoxLayout);
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
QLabel *img = new QLabel();
ui.scrollArea->layout()->addWidget(img);
img->setPixmap(QPixmap::fromImage(image));
img->repaint();
}
so the images appears like I wanted row by row... but no scrollbar appears if there are many QLabel objects added...
thx