I know how painter.setWindow works. for example, if I maximize the widget larger, whatever I drew in that widget gets larger also in the same ratio.
but I can't understand what painter.setViewport exactly do. Can anyone explain to me how it works and give me an example?
As the documentation writes, it is the device coordinate system, and not the logical. They are not necessarily equal to each other even though the default is the same.
This functionality mostly presents because of the API compatibility. That was necessary at the Qt 3 days before the real transformation feature support.
You can do everything with translate and scale what you can also do with viewports. It is just personal preference, albeit the former is more inline with the Vector API in Qt.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With