質問

How can I resize a QLabel and be able to retain its current position? What I want to do is basically resize it, but I want this to be resized from all four sides equally instead of resizing from top-left corner. In other words I want to change the resize point of a widget.

I can accomplish what I'm describing above by basically resizing and repositioning the widget once it has been resize but this is a tedious process and I'm wondering if there is a better way.

I'm not sure if I'm explaining this right, I hope it makes sense.

役に立ちましたか?

解決

You can resize and reposition the widget in one go using QWidget::setGeometry(), taking the new position and size as rectangle (QRect). There's no ready-made function for your exact requirement, but you can of course write a little helper function doing the math.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top