PDA

View Full Version : Created sub-menus slots won't work



thefatladysingsopera
2nd September 2011, 18:42
I have created two sub menus in my save button using the code below.


QMenu *menu = new QMenu(this);

QAction *saveAction = menu->addAction("Save New");
QAction *editAction = menu->addAction("Save Edits");

ui.saveButton->setMenu(menu);

connect(saveAction, SIGNAL(triggered()), this, SLOT(saveNew()));
connect(editAction, SIGNAL(triggered()), this, SLOT(saveEdits()));

The project compiles without any errors but when i click any of the sub-menus i have created,the saveAction or the editAction slots won't execute.

What i am i doing wrong?.

high_flyer
5th September 2011, 16:26
Did you not forget to use the 'slots' or Q_SLOTS in your header?
Are you slots private perhaps?
Is the slot signature correct?

stampede
5th September 2011, 16:29
Also, check your app console output, Qt will print warning messages if connect statement is not correct (invalid signal / slot names etc).