class QPopupMenu;class MyDialog : public QDialog{ Q_OBJECTpublic: MyDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); ~OrganizationHandbookDialog(); QPopupMenu *p_my; protected: QGridLayout* MyDialogLayout; QSpacerItem* spacer5; QGridLayout* frame4Layout; QSpacerItem* spacer4; QGridLayout* groupBox8Layout;protected slots: virtual void languageChange();private: void init();private slots: void func(int);};
void MyDialog::init(){ create();}void MyDialog::create(){ p_my = new QPopupMenu(this); headerMenu->insertItem(tr(""), 0); headerMenu->insertItem(tr(""), 1); headerMenu->setCheckable(true); QObject::connect(p_my, SIGNAL(activated(int)), this, SLOT(func(int)));}
void MyDialog::func(int num){ QMessageBox::warning(this, tr(""), tr(""));}
<connections> <connection> <sender>closeButton</sender> <signal>clicked()</signal> <receiver>MyDialog</receiver> <slot>close()</slot> </connection> <connection> <sender>addButton</sender> <signal>clicked()</signal> <receiver>MyDialog</receiver> <slot>add()</slot> </connection> <connection> <sender>deleteButton</sender> <signal>clicked()</signal> <receiver>MyDialog</receiver> <slot>remove()</slot> </connection> <connection> <sender>editButton</sender> <signal>clicked()</signal> <receiver>MyDialog</receiver> <slot>edit()</slot> </connection></connections><includes> <include location="local" impldecl="in implementation">mydialog.ui.h</include></includes><slots> <slot>setTable()</slot> <slot access="private" specifier="non virtual">add()</slot> <slot access="private" specifier="non virtual">remove()</slot> <slot access="private" specifier="non virtual">edit()</slot> <slot>updateTable()</slot></slots><functions> <function access="private" specifier="non virtual">init()</function></functions>
#include <qobject.h>void MyDialog::init(){ create(); updateTable(); setTable();}void MyDialog::create(){ headerMenu = new QPopupMenu(this); QObject::connect(headerMenu, SIGNAL(activated(int)), this, SLOT(show(int)));}void MyDialog::openHeaderMenu(QMouseEvent *event){}void MyDialog::show(int num){}void MyDialog::setTable(){}void MyDialog::add(){}void MyDialog::remove(){}void MyDialog::edit(){}void MyDialog::updateTable(){}
C++ (Qt)private slots: void func(int);