title: C++ Qt setting up signal and slots for QMenu
body: <p>I am trying to make a make a program that allows a user to right click a cell in a gridView and choose from a menu of actions.</p>
  
  <p>I have the menu display, but am having trouble getting the signal and slot to work without getting errors. I am working in Qt 5.5 C++11, not very advanced with Qt or C++ yet so any help would be greatly appreciated</p>
  
  <pre><code>using namespace std;
  QStandardItemModel* model;
  QStandardItem *value;
  
  MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      ui-&gt;setupUi(this);
      model = new QStandardItemModel(9,9,this);
  
      ui-&gt;tableView-&gt;setModel(model);
      ui-&gt;tableView-&gt;setShowGrid(true);
      ui-&gt;tableView-&gt;setWordWrap(true);
      //to allow menu
      ui-&gt;tableView-&gt;setContextMenuPolicy(Qt::CustomContextMenu);
  
  for(int row = 0; row &lt; 9; row++){
              ui-&gt;tableView-&gt;setRowHeight(row, 75);
              for(int col = 0; col &lt; 9; col++){
                  ui-&gt;tableView-&gt;setColumnWidth(col, 75);
                  QFont f("Consolas");
  
                  f.setPointSize(10);
                  value = new QStandardItem(QString("1 2 3\n4 5 6\n7 8 9"));
  
  
                  if ((row &lt; 3 &amp;&amp; col &lt; 3) || (row &gt; 5 &amp;&amp; col &lt; 3)
                          || (row &lt; 3 &amp;&amp; col &gt; 5) || (row &gt; 5 &amp;&amp; col &gt; 5)
                          || ((row &gt; 2 &amp;&amp; row &lt; 6) &amp;&amp; (col &gt; 2 &amp;&amp; col &lt; 6))){
                      QBrush b(QColor("Moccasin"));
                      value-&gt;setBackground(b);
                  }
  
                  value-&gt;setFont(f);
                  value-&gt;setTextAlignment(Qt::AlignCenter);
                  model-&gt;setItem(row,col,value);
              }
          }
  
          //connects model so functions run when a cell's text is changed
          connect(model, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(on_cell_changed(QStandardItem*)));
          //this sets up the menu
          connect(ui-&gt;tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(menuRequest(QPoint)));
  
      }
  </code></pre>
  
  <p>this is the main window part of the program. It is (going to be) a sudoku solver, so the model represents the 9x9 grid and the for loop is populating the grid with choices for input (but that's not the thing I'm having trouble with). I need help with the menu part below (the above was just for context):</p>
  
  <pre><code>void  MainWindow::menuRequest(QPoint pos)
  {
      QModelIndex index = ui-&gt;tableView-&gt;indexAt(pos);
      std::cout &lt;&lt; "MainWindow::menuRequest - at" &lt;&lt; " QModelIndex row = " &lt;&lt;
                   index.row() &lt;&lt; ", column = " &lt;&lt; index.column() &lt;&lt; std::endl;
      QMenu   menu(this);
  
      QMenu setValues("Initialize Grid", this);
      QAction *setValue1;
      QAction *setValue2;
      QAction *setValue3;
      QAction *setValue4;
      QAction *setValue5;
      QAction *setValue6;
      QAction *setValue7;
      QAction *setValue8;
      QAction *setValue9;
      setValue1 = setValues.addAction("Set value to 1");
      setValue2 = setValues.addAction("Set value to 2");
      setValue3 = setValues.addAction("Set value to 3");
      setValue4 = setValues.addAction("Set value to 4");
      setValue5 = setValues.addAction("Set value to 5");
      setValue6 = setValues.addAction("Set value to 6");
      setValue7 = setValues.addAction("Set value to 7");
      setValue8 = setValues.addAction("Set value to 8");
      setValue9 = setValues.addAction("Set value to 9");
  
      connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(on_menu_clicked(QAction*)));
  
      menu.addMenu(&amp;setValues);
      QAction *action = menu.exec(
                  ui-&gt;tableView-&gt;viewport()-&gt;mapToGlobal(pos));
  
  }
  
  void MainWindow::on_menu_clicked(QAction*){
      cout &lt;&lt; "test menu click worked";
  }
  </code></pre>
  
  <p>The connect statement in the MenuRequest function is throwing an error:</p>
  
  <pre><code>connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(on_menu_clicked(QAction*)));
  </code></pre>
  
  <p>C2664: 'QMetaObject::Connection QObject::connect(const QObject *, const char *, const char *, Qt::ConnectionType)const' : cannot convert argument 1 from 'QMenu' to 'const QObject *'</p>
  
  <p>When it is supposed to go to the on_menu_click function it throws the above error</p>
  
  <p>I know that means that menu isn't of the QObject type but I'm not sure how to fix this. Any help would be greatly appreciated</p>