Closed markotoplak closed 4 years ago
I've just tried this and it's rather tricky. You can set the splitter's style __splitter.setStyle(QStyleFactory.create("fusion"))
to one of available styles, which depend on your platform. On my windows machine it's "windows" or "fusion". The latter looks like your Ubuntu version.
Another option is to set the style of the handle using stylesheets (setStyleSheet("background-color: red")
). Unfortunatelly, it seems that some styles ignore certain stylesheet parameters as I can set the background color but not a background image.
At this point, I'm a bit out of my Qt depth.
On Windows, the splitter is thinner. We can have either a smaller indicator
(enlarge the picture)
or we can make the splitter wider.
I guess I like the narrow one - in my temporary opinion it is just bit enough to perhaps tell the user that there's something to click there. @markotoplak?
Should anybody wish to play: the following code needs to be added to the _Handle
class in widget.py.
Narrow:
class _Handle(QSplitterHandle):
def paintEvent(self, event):
super(QSplitterHandle, self).paintEvent(event)
painter = QPainter(self)
painter.setBrush(QColor(192, 192, 192))
painter.setPen(QColor(160, 160, 160))
painter.drawEllipse(self.width() / 2 - 1, self.height() / 2 - 1, 2, 2)
For the wider, increase the necessary number in the last line, plus call self.setHandleWidth(10)
on the splitter class.
(We would of course add a condition to run this only on Windows.)
As we are using the splitter in a less standard way, for showing and hiding something, we could go for some custom visual that would be the same on all platforms.
Makes sense. The circle that we have now is not recognizable, I wouldn't be tempted to click it.
What about this -- on all platforms?
Very much in favour of the little arrow.
On Macs, for example, we see a good enough visual indication of the splitter:
On stock Ubuntu, less so:
While on Windows we only see a cursor change on mouse over.
As we are using the splitter in a less standard way, for showing and hiding something, we could go for some custom visual that would be the same on all platforms.