This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How to Create Context Menu?

Tags: None
(comma "," separated)
kalle1950
Registered Member
Posts
16
Karma
0

How to Create Context Menu?

Thu Jan 07, 2010 1:14 pm
Hi,

I want to have a context menu (in a QTreeWidget in case that matters). I have no clue how to get this context menu (these menus you get when you click with the right mouse button).

I only found QContextMenuEvent, do I have to use this? Does someone have a tutorial how to use it to get a context menu? Or at least a code sample?

Is there something KDE specific?

Thanks.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

Re: How to Create Context Menu?

Thu Jan 07, 2010 10:25 pm
This is only handled by Qt, nothing KDE specific.

You need to set the context menu policy to Qt::CustomContextMenu then connect the customContextMenuRequested signal to one of your slots. In this slot you create and show the context menu at the supplied position.

See the QWidget documentation for more information.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]