Hey trolls,
I'm using a 1 pixel QSplitter.
The only problem is... since it's a 1 pixel QSplitter it's difficult to drag / drop.
Is there a way to have a 1 pixel Graphical splitter and keeping a 5 pixels draggable area ?
Printable View
Hey trolls,
I'm using a 1 pixel QSplitter.
The only problem is... since it's a 1 pixel QSplitter it's difficult to drag / drop.
Is there a way to have a 1 pixel Graphical splitter and keeping a 5 pixels draggable area ?
You can provide your own handle for the splitter. If you paint only one pixel and keep the remaining four transparent maybe you will obtain your effect.
How did you create a 1 pixel QSplitter?
I've created QSplitter and added to QListView objects to it. How can I make a separator( between QListView objects) to be 3 pixels width? setHandleWidth() changes only the dragable area...
Here is the implementation for a 1 pixel painted + 4 pixels draggable area.
(this code is from QtCreator, licensed in GPL)
Doesn't seem to work on Qt 4.4.3, anyone could confirm this ?
Code:
#include "minisplitter.h" #include "stylehelper.h" #include <QtGui/QPaintEvent> #include <QtGui/QPainter> #include <QtGui/QSplitterHandle> namespace Core { namespace Internal { { public: { setAttribute(Qt::WA_MouseNoMask, true); } protected: }; } // namespace Internal } // namespace Core using namespace Core; using namespace Core::Internal; { if (orientation() == Qt::Horizontal) setContentsMargins(2, 0, 2, 0); else setContentsMargins(0, 2, 0, 2); } { painter.fillRect(event->rect(), StyleHelper::borderColor()); } { return new MiniSplitterHandle(orientation(), this); } { setHandleWidth(1); setChildrenCollapsible(false); setProperty("minisplitter", true); } MiniSplitter::MiniSplitter(Qt::Orientation orientation) { setHandleWidth(1); setChildrenCollapsible(false); setProperty("minisplitter", true); }
I believe there is a small piece of extra code defined in the manhattanstyle.cpp files
Code:
{ if (type == CT_Splitter && widget && widget->property("minisplitter").toBool()) else if (type == CT_ComboBox && panelWidget(widget)) return newSize; }