I don't know if I did something wrong, but it seems that adding a widget to a QScrollArea in Designer and then promoting it doesn't do the trick. I had to manually add a widget to the scroll area for the scroll bars to finally appear.
ui.scrollArea->setWidget(new DropArea(ui.scrollArea));
ui.scrollArea->setWidget(new DropArea(ui.scrollArea));
To copy to clipboard, switch view to plain text mode
In Designer, first I created a QScrollArea. Then I took a QFrame and dragged it onto the QScrollArea until it was highlighted, so that it was clear that I'm adding the QFrame _to_ it. Then I promoted the QFrame to a DropArea (my custom class). That's the right way to do it isn't it?
After I spent hours of tinkering with the layout and sizes and the scrollbars just wouldn't appear, I created a minimal example and figured out that only an explicit scrollArea->setWidget(dropArea) will make it work right.
So then I went back to what I created with Designer and tried to make sure that the dropArea is set as widget of the scrollArea like this:
ui.scrollArea->setWidget(ui.dropArea);
ui.scrollArea->setWidget(ui.dropArea);
To copy to clipboard, switch view to plain text mode
The program crashes without any messages. I also checked if the ui.dropArea and the ui.scrollArea->widget() pointers are the same, they are not. So I think it must be so that Designer doesn't setWidget().
Bookmarks