KPopupMenu Class Reference

[kio Index] [kio Hierarchy] [Headers]


Popup menu with title. More...

#include <kpopmenu.h>

Inherits: QPopupMenu (qt)

Public Members


Detailed Description

Here's a popup menu widget for KDE apps. It differs from Qt popup menu in

that it has a title -- thus it is *not* to be used in a menu bar. Only two

new methods are added -- setTitle(char *) and title() and a new constructor,

taking the title as a first argument. The main API difference from Qt's

QPopupMenu is that you should *not* expect the first item you insert into

KPopupMenu to have index (an ID) 0! So the following is wrong:

KPopupMenu menu("Window operations");

menu->insertItem("Move");

menu->insertItem("Minimize");

menu->insertItem("Close");

menu->connectItem(0, this, SLOT(moveWindow())); // WRONG!!!

menu->connectItem(1, this, SLOT(minimizeWindow())); // WRONG!!!

menu->connectItem(2, this, SLOT(closeWindow())); // WRONG!!!

The reason is that the title and a double line (actually, two separators) are

stored as menu items too, so the first item you insert has index 3. There's

a constant KPM_FirstItem so use one of those approaches instead of the above:

[1] int move_item = menu->insertItem("Move");

...

menu->connectItem(menu_item, this, SLOT(moveWindow()));

[2] menu->insertItem("Move");

...

menu->connectItem(KPM_FirstItem+0, this, SLOT(moveWindow()));

[3] The best one!

menu->insertItem("Move", this, SLOT(moveWindow()));



  • Version: $Id: KPopupMenu.html.in,v 1.1.1.1 2000/02/09 22:27:33 tasin Exp $
  • Documentation generated by tasin@cd1 on Die Nov 30 17:32:00 CET 1999
Kdoc