From what you have said, a factory would help. The keyboard would be a keyboard only, none of these signal + slots needed just for initialisation data. All that rigmarole can be abstracted away in a factory. Depending on your differing instrument or keyboard usage, merely create the keyboard directly for the trivial case, or use a different concrete factory.


As for heap vs stack, if you don't know why one is very frowned upon in such examples, I suggest you do some further reading