Humm, so far I managed to do:

Qt Code:
  1. QAction* randomize = new QAction(this);
  2. randomize->setText("Randomize");
  3. connect(randomize, SIGNAL(triggered()), this, SLOT(test()));
  4. ui->spinBox->addAction(randomize);
To copy to clipboard, switch view to plain text mode 

and changed in desinger, spinBox contextMenuPolicy to actionsContextMenu.

This works fine but I want to keep the default options (Undo, redo, copy, paste etc.) and only append mine option at the end.

I checked what you gave me there Lykurg, but cannot figure out much of this.