When the application is launched but yet in construction time (when all the initial widget is being created and so on), I add to my layout a QSplitter
, with two widgets, and I want the second widget occupies more or less the 60/70% of the available space, while the first widget takes the rest of the space (taking into account the splitter size itself).
So, in the beginning, before the windows itself is shown, I try to readjust these two widget more or less like that:
splitter->setOrientation(Qt::Vertical);
auto sizes = splitter->sizes();
int& first_w = sizes.front(); // == 0
int& second_w = sizes.last(); // == 0
int diff = form_w * 2.3 - tbl_w; (30% * 2.3 = ~70%)
second_w += diff;
first_w -= diff;
splitter->setSizes(sizes);
But, first_w
and second_w
contains 0
and 0
, I don't know if because the sizes have not been calculated yet, or because the widget is not yet shown (the window isn't) and the sizes of invisibles widgets are 0
.
What can I do to get the "future" sizes of these widgets? The splitter
is inside a QVBoxLayout
, and the available space of the owner widget is more or less all the vertical space of the window (there's only a QTabBar
above the widget owning that QVBoxLayout
, and a bit of padding in the window).