Both loops look strange. As far as I understand you'd like the label to show the values staring from 1 up to 2 ^ sizeof(int) - 1
  1. The second value is platform dependant
  2. Even if you move your loop to other place, ie to the constructor of MainWindow, you won't notice label's changes. You should make sure that label's paintEvent occurs each time you do label->setNum().