void MainWindow::addMenu( char* name, const char* slot ){ QAction* action = new QAction(tr( name ) ); if( action ) { contextMenu->addAction( action ,contextMenu) ); connect( action, SIGNAL(triggered()), this, slot ); }}
... case OVERWORD: addMenu( "Копировать", SLOT(slotCopy()) ); addMenu( "Вставить", SLOT(slotPaste()) ); addMenu( "Вырезать", SLOT(slotCut()) ); addMenu( "Удалить", SLOT(slotDelete()) ); ...
void MainWindow::contextMenuEvent(QContextMenuEvent *event) { QMenu menu(this); menu.addAction(cutAct); menu.addAction(copyAct); menu.addAction(pasteAct); menu.exec(event->globalPos()); }
QWidget::~QWidget ()Destroys the widget.[b]All this widget's children are deleted first.[/b]