I using paint event to draw text in Qwidget . when i am starting widget in maximized text is disaplay at x=0,y=0 but when resize text is not showing at x=0,y=0 it is showing from middel of mywidget what is the issue can you tell me. Below is my code
int width = size().width() ; int height = size().height(); painter.fillRect(0, 0, width, height, QColor(220,220,220)); painter.drawText(10, 10, "Machine");
Code looks fine. should not move as its fixed at 10,10
Could it be that your widget is in layout and layout move widget when you resize window?
how exactly do you position your widget you are painting on?
painter.fillRect(0, 0, width, height, QColor(220,220,220));
Since you are doing the above paint command, your text should be at 10,10 in relation above painted rectangle. Also QColor(220,220,220) is almost white, you can change the color to QColor(0,0,255) and see where is your widget. This should help you to fix the issue.