Hi I'm trying to use a QScrollArea to manage the size of a certain widget.
This widget is a list of smaller widgets (using a QVBoxLayout) which can be dynamically resized and which starts empty, and hence invisible.
I can fully see and use the widget if I set it as the central widget of a QMainWindow. this means I can add widgets to the list, delete them etc.. and I can see everything.
Then I decided I'd like some scroll bars to manage the size of the window. So I figured I could just create a QScrollArea, set the widget as the QScrollArea widget, and then set the QScrollArea as the central widget of the main window. I didn't do any configuation of size policies or anything thinking that I'd at least see something (anything!) first. The result is that I can't see anything. The widget is simply not visible.
I have been reading the documention on size policies and what not on the QScrollArea page, but I have totally failed to understand this. I just can't understand why not setting some of these things have caused my widget to become totally invisible even when I add widgets to the list.
Again, when I set this widget as the central widget of a QMainWindow, everything works as expected. The pseudo code is:
mainWindow the_window;
listWidget the_list;
the_window.setCentralWidget(&the_list);
mainWindow the_window;
listWidget the_list;
the_window.setCentralWidget(&the_list);
To copy to clipboard, switch view to plain text mode
The above gives a working widget, without scroll bars
mainWindow the_window;
listWidget the_list;
the_area->setWidget(&the_list);
the_window.setCentralWidget(&the_list);
mainWindow the_window;
listWidget the_list;
QScrollArea* the_area = new QScrollArea();
the_area->setWidget(&the_list);
the_window.setCentralWidget(&the_list);
To copy to clipboard, switch view to plain text mode
The above gives a window with nothing in it, no matter how many widgets I add to the list.
If it's helpful, I'm using Qt 4.8.4 on ubuntu 13.10.
Bookmarks