Let me guess... If you modified the application example you should have the following:
Qt Code:
  1. //mainwindow.h
  2. //[SKIP]
  3. class MainWindow : public QMainWindow
  4. {
  5. Q_OBJECT
  6. public:
  7. MainWindow();
  8. //[SKIP]
  9. private slots:
  10. void newFile();
  11. //[SKIP]
  12. void documentWasModified();
  13. void indexEnv(); // (1)
  14. private:
  15. void createActions();
  16. //[SKIP]
  17. QMenu *editMenu;
  18. QMenu *helpMenu;
  19. QMenu *yourOwnMenu; // (3)
  20. //[SKIP]
  21. QAction *aboutAct;
  22. QAction *aboutQtAct;
  23. QAction *showYourOwnMenuAction; // (2)
  24. };
  25.  
  26. //mainwindow.cpp
  27. //[SKIP]
  28. void MainWindow::createActions()
  29. {
  30. //[SKIP]
  31. showYourOwnMenuAction = new QAction(tr("Show Preview Window"), this); // (2)
  32. showYourOwnMenuAction->setStatusTip(tr("Show Preview Window from the <i>Windows flags</i> example"));
  33. connect(showYourOwnMenuAction, SIGNAL(triggered()), this, SLOT(indexEnv())); // (5)
  34. //[SKIP]
  35. }
  36. void MainWindow::createMenus()
  37. {
  38. //[SKIP]
  39. yourOwnMenu = menuBar()->addMenu(tr("&Your Menu")); // (3)
  40. yourOwnMenu->addAction(showYourOwnMenuAction); // (4)
  41. //[SKIP]
  42. }
To copy to clipboard, switch view to plain text mode 
To achieve the result you need you should do these steps:
  1. Implement your indexEnv() as a slot, so that you can connect() to it
  2. Create a QAction, which is to be triggered() when the user clicks on the corresponding menu item
  3. Create the menu itself
  4. Make your action available through the menu
  5. connect() the QAction's triggered() signal to your MainWindow's indexEnv() slot