Dawid Sip wrote:
> Hi,
> Im having problems with adjusting the sizes of the widget in my
> splitters. I have two splitters, a vertical and a horizontal one. The
> father of the horizontal splitter is the vertical splitter and I use the
> following code piece to add the widget to the splitters:
>
...
>
> What happens in th switch is. case 1: The dockWid is added and it takes
> the whole area of the centralWidget() - Good. Then in case 2: The second
> widget is added horizontally and both widget are resized so they have
> equal widths and heihts (they splitt the central widget area equally) -
> God. And for case 3: The third dockWid is added Vertically beneath both
> upper widget but unfortunately it takes most of the space, something
> like 80% of the centralWidget() height. I would like it to also split
> the centralwidgets height equally between it and the upper two widgets.
> As you can see I tryed to do it with the resize(centralWidget().width(),
> centralWidget().height() / 2); but it wont work. I also tryed variuos
> sizePolicy setups but apparently I dont understand something.
> I'd be thankfull for all the help.
>
> Dave
Hi Dave,
Your dockwidgets probably don't have any content, and thus, no sizeHint.
This makes means the layout go a bit nuts as it the widgets don't
indicate what size they would prefer to be. Without a sizeHint the
sizePolicy has no meaning. I've given the widgets a sizeHint of 200x200
in the example below and then they stretch out evenly. Hope this helps
best regards,
Gunnar
import com.trolltech.qt.core.*;
import com.trolltech.qt.gui.*;
public class Splitters {
public static class Box extends QDockWidget {
public QSize sizeHint() {
return new QSize(200, 200);
}
}
public static void main(String args[]) {
QApplication.initialize(args);
QSplitter hSplitter = new QSplitter(Qt.Orientation.Horizontal);
QSplitter vSplitter = new QSplitter(Qt.Orientation.Vertical);
vSplitter.addWidget(hSplitter);
hSplitter.addWidget(new Box());
hSplitter.addWidget(new Box());
vSplitter.addWidget(new Box());
vSplitter.show();
QApplication.exec();
}
}
_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest