I\'m trying to pass an enum as a value to a slot in my program, but I\'m having some problems. In my header file I\'ve created the enum:
Q_ENUMS(button_type);
e
Signal and Slot need to have the same parameters. What you want is a QSignalMapper.
edit:
Here is an example from an application of mine. It creates 10 menu actions that each are connected to the same slot gotoHistoryPage
but each called with a different int
value.
m_forwardMenu = new QMenu();
for(int i = 1; i<=10; i++)
{
QAction* action = m_forwardMenu->addAction(QString("%1").arg(i));
m_forwardActions.push_back(action);
m_signalMapper->setMapping(action, i);
connect(action, SIGNAL(triggered()), m_signalMapper, SLOT(map()));
}
ui.forwardButton->setMenu(m_forwardMenu);
connect(m_signalMapper, SIGNAL(mapped(int)), this, SLOT(gotoHistoryPage(int)));