I am puting a QWidget and a QTabWidget next to each other in one horisontal splitter. And the splitter loses it\'s shape, you can know that there is a splitter only by hovering
I based this on the above code but it handles both splitter orientations. I just preferred non-opaque resizing and non-collapsible children. The grip consists of three parallel lines. You can play with the handle width, but grip at 7 looks good on Windows; haven't checked in Linux or Mac.
void helper::decorateSplitter(QSplitter* splitter, int index)
{
Q_ASSERT(splitter != NULL);
const int gripLength = 15;
const int gripWidth = 1;
const int grips = 3;
splitter->setOpaqueResize(false);
splitter->setChildrenCollapsible(false);
splitter->setHandleWidth(7);
QSplitterHandle* handle = splitter->handle(index);
Qt::Orientation orientation = splitter->orientation();
QHBoxLayout* layout = new QHBoxLayout(handle);
layout->setSpacing(0);
layout->setMargin(0);
if (orientation == Qt::Horizontal)
{
for (int i=0;isetMinimumSize(gripWidth, gripLength);
line->setMaximumSize(gripWidth, gripLength);
line->setFrameShape(QFrame::StyledPanel);
layout->addWidget(line);
}
}
else
{
//this will center the vertical grip
//add a horizontal spacer
layout->addStretch();
//create the vertical grip
QVBoxLayout* vbox = new QVBoxLayout;
for (int i=0;isetMinimumSize(gripLength, gripWidth);
line->setMaximumSize(gripLength, gripWidth);
line->setFrameShape(QFrame::StyledPanel);
vbox->addWidget(line);
}
layout->addLayout(vbox);
//add another horizontal spacer
layout->addStretch();
}
}