I've ported the Python itertools code listed here (using generators). The advantage over the solutions posted so far is that it allows you to specify r (permutation size).
You don't have to create a QVBoxLayout manually. Just select your central QWidget and press a make-layout button
https://stackoverflow.com/a/1508954
Add at least one widget on your MainWindow. Then select your window by clicking on it and click on the VerticalLayout Button at the top of QTCreator. You Vertical Layout is automatically added to the central widget and fills all the surface. https://stackoverflow.com/a/1508969