[Kde-perl] Right Click Menu
Richard Dale
Richard_Dale at tipitina.demon.co.uk
Sat Aug 30 19:17:52 CEST 2003
On Saturday 30 August 2003 17:34, Steffen Liebergeld wrote:
> Hi,
>
> Iam writing a program (using perl-Qt) including a Qt::ListView Widget.
> But I can´t figure out how to add a right-mouse-click menu to this
> widget.
>
> I would be pleased if you could give me a hint.
You need to create a popup menu, and subclass Qt::ListView to override
mousePressEvent to show the menu if 'event.button() == RightButton'. Here is
an example in perl (this might be wrong, I haven't tried the code):
$popupmenu = Qt::PopupMenu();
$popupmenu.insertItem("&Clear", this, SLOT("slotClearArea()"));
sub mousePressEvent() {
if ($_[0].button() == RightButton) {
$popupmenu.exec(Qt::Cursor.pos());
...
}
}
-- Richard
PS: And in ruby:
@_popupmenu = Qt::PopupMenu.new()
@_popupmenu.insertItem( "&Clear", self, SLOT( "slotClearArea()" ) )
...
def mousePressEvent(event)
if event.button() == RightButton
@_popupmenu.exec( Qt::Cursor.pos() )
...
end
end
More information about the Kde-perl
mailing list