PDA

View Full Version : Question about setContentsMargins for QSplitter



TorAn
23rd December 2009, 15:28
I have a form with two splitters, splitter and splitter_2. Fig 1. shows the form in the Qt Designer.
http://www.tradeplatform.us/sp-1.jpg
Fig.1

In run-time I want to assign margins to the splitters so that encompassed widgets would not "stuck" to the handles of these splitters. I the constructor I have this:

ui.setupUi(this);

ui.splitter->setContentsMargins (10,10,10,10);
ui.splitter_2->setContentsMargins (10,10,10,10);

and never else in this form class I am programmatically changing splitter's properties

Fig 2 shows results.

http://www.tradeplatform.us/sp-2.jpg
Fig.2

Splitter_2 indeed took the margins, but "splitter" on the left side did not. Widgets are still "stuck" to left splitter. (Rectangles around splitters handles are painted by me in run-time, subclassing QSplitterHandle)

Questions are:
1. Why is splitter_2 works and splitter does not
2. How to make it work so that the widgets are not stuck to the splitter's handle? (preferrably without spacers)