QSplitter - sizes() return 0?
-
wrote on 1 Jul 2014, 12:40 last edited by
I'm having problem setting initial sizes for my QSplitter. What's odd is if I check the initial sizes before setting them with "ui->splitter->sizes();" I get 0 for both layout inside the QSplitter.
The check is made after the setupUI call, I have tried many things but it always return me 0 for sizes. What's even more odd is that I have another GUI similar that is working with a QSplitter. If anyone have experience with this kind of problem with QSplitter any help would be appreciated!
See my interface here :
https://www.dropbox.com/s/4sc0hae393ur5fg/splitterPRob.pngI tried changing the vertical layout to a grid layout like #2, still not working, any ideas appreciated ;)
Qt doc says : Note that invisible widgets have a size of 0. : both of my widget are visible!@ QList<int> sizeNow = ui->splitter->sizes();
for(int i=0; i<sizeNow.length(); i++) {
qDebug() << "SIZE here" << sizeNow.at(i); /// return 0...
}@ -
Hope splitter is displayed with splitter.show(). If the splitter is not shown, size is not set. It will set sizes only if they are shown.
-
wrote on 1 Jul 2014, 13:11 last edited by
Hi,
Yes the splitter is show and working, the problem is only getting it's initial sizes (return 0) and settings it's size.
The splitter is added directly inside the ui file (designer) -
QSplitter will get the sizes only if the widgets inside the splitter are shown. Otherwise it returns zero.
@ // See the code snippet. It shows correct result
split.show();
QList<int> sizes = split.sizes();
for(int i=0;i<sizes.length();i++){
qDebug() << "Hello =" << sizes.at(i); // Returns the size
}// See the below code snippet. It return zero QList<int> sizes = split.sizes(); split.show(); for(int i=0;i<sizes.length();i++){ qDebug() << "Hello =" << sizes.at(i); // Returns the ZERO }@
-
wrote on 1 Jul 2014, 15:31 last edited by
Hi,
I added a .show() before just to make sure :
@ ui->splitter->show();
QList<int> sizeNow = ui->splitter->sizes();
for(int i=0; i<sizeNow.length(); i++) {
qDebug() << "SIZE here" << sizeNow.at(i);
}@log :
SIZE here 0
SIZE here 0I have a QHBoxLayout and a custom QWidget in the Vertical splitter. both are shown on the screen and visible..
1/5