I have a freeflow layout inside a scrollarea that when new labels get added to that freeflow layout the scrollarea does not work. The scrollbar never changes even if I resize the form.

Here is some code

Qt Code:
  1. #include <QtGui>
  2.  
  3. #include "flowlayout.h"
  4. #include "window.h"
  5. #include "dropsitewidget.h"
  6.  
  7. Window::Window()
  8. {
  9.  
  10. // setting up the debig textbox
  11. this->log = new QTextEdit;
  12.  
  13.  
  14. // setting up the flow layout
  15. this->flowLayout = new FlowLayout;
  16. this->flowLayout->setSizeConstraint(QLayout::SetMinimumSize);
  17.  
  18. QScrollArea *scrollArea = new QScrollArea;
  19. scrollArea->setLayout(this->flowLayout);
  20.  
  21. // adding the 20 labels for images
  22. for (int i=0; i<20; i++) {
  23. //this->flowLayout->addWidget(new QLabel(tr("its a label")));
  24.  
  25. QLabel *label = new QLabel("image here");
  26. label->setFixedSize(100,100);
  27.  
  28. this->labelList.append(label);
  29. this->flowLayout->addWidget(this->labelList.at(i));
  30. }
  31.  
  32. // adding the widget to do the drag and drop
  33. dropSiteWidget = new DropSiteWidget;
  34. connect(dropSiteWidget, SIGNAL(sendLog(QString)), log, SLOT(append(QString)));
  35. connect(dropSiteWidget, SIGNAL(sendImage(QString)), this, SLOT(newImage(QString)));
  36.  
  37.  
  38.  
  39. QVBoxLayout *layout = new QVBoxLayout;
  40. layout->addWidget(dropSiteWidget);
  41. layout->addWidget(scrollArea);
  42. layout->addWidget(log);
  43. setLayout(layout);
  44.  
  45. this->count = 0;
  46.  
  47. setWindowTitle(tr("Flow Layout"));
  48. }
  49.  
  50. void Window::newImage(QString str) {
  51. // loading the new image
  52. QPixmap *img = new QPixmap(str);
  53.  
  54. // checking if its a valid image
  55. if (!img->isNull()) {
  56. // scaling the image now
  57. QPixmap smallImg;
  58. smallImg = img->scaledToWidth(100);
  59.  
  60. this->labelList.at(this->count)->setPixmap(smallImg);
  61. this->count++;
  62. }
  63. }
To copy to clipboard, switch view to plain text mode 


freeflow and dragdropwidget are taken from the examples