PDA

View Full Version : How to hide the handle of QSplitter?



Ashkan_s
15th October 2012, 10:01
How can I hide the handle of the QSplitter?

And

How to change its appearance to a line, like splitters in Qt Creator? QSplitter::setHandleWidth(1) doesn't have the effect.

wagmare
15th October 2012, 10:36
not the best suggestion but try this also ...

use the stylesheet of QSplitter and adda dummy icon

QSplitter::handle {
image: url(images/Dummy.png);
}

Ashkan_s
15th October 2012, 13:10
using
splitter->setHandleWidth(1);
qApp->setStyleSheet("QSplitter::handle{background-image: url(:/images/img-1.png);}");
or
splitter->setHandleWidth(1);
qApp->setStyleSheet("QSplitter::handle{background-color: black;}");

it is possible to change its appearance to look like a line.
Still I'm not able to hide the handle.

Ashkan_s
15th October 2012, 23:32
My original question needs to be changed and reworded -It is possible to hide the handle but it is not useful- How can I make the handle indistinguishable from widgets around it? In other words How to camouflage the handle?

What I have done so far:
I have painted the handle in white by sub-classing QSplitterHandle and QSplitter and re-implementing the QSplitterHandle::paintEvent like this:
void SplitterHandle::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.fillRect(event->rect(), Qt::white);
}
It is not enough because two black lines are visible around the handle, these are borders of the widgets in the splitter.
I have tried to paint the borders of the a widget (a QTreeWidget) in white:
treeWidget.setStyleSheet("border-color: white;");But this has no effect.
Now the question is How to change the border-colors of a widget?

P.S.
To hide the handle it is possible to re-implementing its showEvent and call hide() :cool:


Added after 1 55 minutes:


To hide the handle it is possible to re-implementing its showEvent and call hide()

It is possible to hide the handle but it is not useful
It can be useful! With some work it is possible to make the handle visible again, thus it is possible to alternate the state between visible and hidden.

Still I need to know How to change border-colors of a widget.

Ashkan_s
16th October 2012, 08:24
Currently I have some problems setting border colors, I will ask them in their own thread.