When no key was ever used, the index is still 0. The default value of a QSpinBox is 0, so the valueChanged signal is not emitted when setting the index, and the keys are not filled until the user increments the spinbox manually.
Fix this by calling the slot manually when the index is 0. Also rename the slot to something more descriptive than onIndexChanged.
Also remove some unneeded synchronization code. The only thing calling this slot is the signal emitted by the spinbox or the new call added in this diff (when the spinbox's value is already 0), so no need to update the spinbox.