1

I have a QSplitter with 2 widgets, and I want to control which widget is shown using buttons. One for the "left" one, one for the "right" one, and the third for both.

  1. How can i make it possible to control the width of the widgets by the user, and to give him a shorter way of doing this.

  2. How can I change the style of the Qsplitterhandle ? now it has the same style/shape/color as the background, so it is impossible to see the Qsplitterhandle.

4

1 回答 1

2

You can collapse and uncollapse a QSplitter programmatically using setSizes. Connecting each of the following slots to your buttons should do the trick.

def onLeft(self):
    self.splitter.setSizes([1, 0])

def onBoth(self):
    self.splitter.setSizes([1, 1])

def onRight(self):
    self.splitter.setSizes([0, 1])

If you want to change the style of your QSplitter handle, you could use StyleSheets.

stylesheet = "QSplitter::handle{background: gray; width: 2px; height: 2px;}"
self.splitter.setStyleSheet(stylesheet )
于 2013-11-07T10:47:50.853 回答