Correct dimension of widgets
-
Hi, how can I view a widget with correct size?
I try to explain...
I've a QLineEdit with maxLength of 40 characters.
This QLineEdit is in a Layout.
When I run my program, I see QLineEdit very short compared to the 40 characters it should contain.
I tried to set a minimum Width size (setMinimumWidth), but I don't think that this is the correct way.
Thanks. -
@Stefanoxjx said in Correct dimension of widgets:
I tried to set a minimum Width size (setMinimumWidth), but I don't think that this is the correct way.
It is.
-
Really?
But exist a method to calculate the correct size? -
@Stefanoxjx said in Correct dimension of widgets:
But exist a method to calculate the correct size?
Yes, QFontMetrics can give you the width of a QString which you can take as a starting point for the needed width.
-
It works fine.
Many thanks.