Drawing non-rectangular buttons?
David Faure
dfaure at klaralvdalens-datakonsult.se
Wed Sep 24 09:46:05 BST 2003
On Tuesday 23 September 2003 23:22, shaheed wrote:
>
> Hi all,
>
> Is it possible without major effort to draw non-rectangular buttons in KDE/Qt?
> Specifically, I want to draw something that approximates a normal keyboard
> button, in particular odd-shaped stuff like L-shaped "enter" keys.
>
> I am aware of QWidget::setMask(), but if I understand correctly, it is a bit
> of a blunt instrument, and it is not clear to me if it would allow, for
> example, another button to intrude into the angle of the L-shaped "enter" key
> as on a real keyboard.
Sounds like a question for qt-interest, but here we go:
You want to use setMask (preferrably with a simple hand-assembled QRegion
than with a QBitmap, for performance reasons). Then you can definitely put
a widget 'on top' of that one, i.e. partially overlapping its rectangular area.
(Obviously you'll have to do your own position to do that, a layout won't do).
And if you want clicks to go to the right button, you'll have to reimplement
QButton::hitButton() (which says yes for the whole rectangle by default).
--
David Faure -- faure at kde.org, dfaure at klaralvdalens-datakonsult.se
Qt/KDE/KOffice developer
Klarälvdalens Datakonsult AB, Platform-independent software solutions
More information about the kde-core-devel
mailing list