This is wrong as i am creating an object of the QPainter. Sorry but now it is solved.