0

I am developing my own widget which is a kind of tree view, and I am facing a little problem : my items are QPushButtons, they are in a QFrame, which is in a scrollArea. When I deploy my items, scroll bars don't appear and I can't use my scroll wheel. I have tried to change the size of my QFrame dynamically but it doesn't work. I have search on the net but I did not found any real good answer.

My widget

My UI

If someone has a clue to resolve the problem, I am interested !

Thanks !

Amott
  • 191
  • 9
  • please add the respective code! – Sir. Hedgehog Jun 22 '16 at 13:34
  • Which part ? Because I have 5 classes and about 1,000 lines. I have a class to create my tree, one to represent my items, one to animate those items, one to connect to a database and the last one to export all of this as a widget in QtDesigner – Amott Jun 22 '16 at 13:52
  • Does [this answer help](http://stackoverflow.com/a/21265287/1329652)? "If someone has a clue to resolve the problem, I am interested!" That might be hard since it's not obvious what you did wrong. All I know is that I can do it right, but that's not helpful, right? We really need to see an [SSCCE](http://www.sscce.org) – Kuba hasn't forgotten Monica Jun 22 '16 at 13:56
  • You don't need to design your widget in Designer if it obfuscates things for you. Probably doing it programmatically might be easier and more concise. As for minimization of the code: don't ask which part. Post enough to reproduce the issue and no more. E.g. don't do any database I/O, use some static or quickly generated data. An ideal question is one that has a single-file `main.cpp` **only** that anyone can take, compile and run to reproduce your issue. – Kuba hasn't forgotten Monica Jun 22 '16 at 13:57
  • Hi Kuba, thanks for your response, I'll take a look to your first link. "That might be hard since it's not obvious what you did wrong", I don't know what I do wrong too. When I deploy me tree I have almost 600 items, and you need the entire code to reproduce the issue. My code works well, it's just when an item goes off the QFrame, scroll bars don't appear. And I must use a database, I have a lot of information to deal with, like link, images, and other datas – Amott Jun 22 '16 at 14:28
  • @Amott You can generate fake data in a few lines of code - a `for` loop doesn't care that it has to run 600 times. Really. I guarantee that you could minimize it to an example that's less than 200 lines, most likely less than 100 lines. – Kuba hasn't forgotten Monica Jun 22 '16 at 17:52

1 Answers1

1

Finally found the solution :

ui->scrollArea->setWidgetResizable(true);
QGridLayout *gridLayout = new QGridLayout(ui->scrollAreaWidget);
ui->frame->setFixedHeight(ui->scrollArea->height());
gridLayout->addWidget(ui->frame,0,0,1,1);

and change fixedHeight when I deploy a node

Amott
  • 191
  • 9