PDA

View Full Version : Signal & Slots with ComboBox



Jack_Holmes
15th December 2015, 21:37
Hello. I am new to Qt and I am trying to use signals and slots.

I have a ComboBox which is part of my UI and has pre-filled values. When I change the value of the ComboBox I would like it to call a function.

This is what I have tried to do (called in my QMainWindow class):



QObject::connect(m_ui.cmbResolution, SIGNAL(currentIndexChanged(int)), this, SLOT(setGameWindowResolution()));


It's also worth mentioning that I tried to do this with a menu item which worked fine:


QObject::connect(m_ui.actionAdd_Empty, &QAction::triggered, m_pSceneManager, &SceneManager::addEmptyGameObject);


Any help would be greatly appreciated, thanks.

EDIT:
Ok - finally got this working. I needed to put my function definition in 'public slots:'