But what is the purpose of all that code? You can get the label width and height by calling width() and height(), you don't need any "windowSize" for that. ev->rect().width() is going to return the width of the exposed rect which can be anything ranging from 1 to the width of your label. Hence your code makes no sense. Your drawing code needs to draw within QRect(0,0, width(), height()).