Resize QPainter
-
Hi, i have a question. Suppose i have a MainWindow where, through paintEvent and QPainter, I draw a rectangle.
I have noticed that if i resize the window, usinge the mouse, the rectangle doesn't change in size, it stays the same.
How can i make the rectangle resize accordingly to the window? -
if i resize the window, usinge the mouse, the rectangle doesn't change in size, it stays the same
Why would it change on its own? You're drawing a rectangle by specifying the size in pixels, so you decide how big it is.
How can i make the rectangle resize accordingly to the window?
You can't make that rectangle resize. It's just drawn pixels. If you want a bigger rectangle you just draw a bigger rectangle. Widgets have a
size(),width()andheight()methods that give you their dimensions. If you want the rectangle to be, for example, half the width of the widget just passwidth()/2as the width of the rectangle when you draw it. -
Hi, i have a question. Suppose i have a MainWindow where, through paintEvent and QPainter, I draw a rectangle.
I have noticed that if i resize the window, usinge the mouse, the rectangle doesn't change in size, it stays the same.
How can i make the rectangle resize accordingly to the window?