how to get the real size of the widget? the result return by the size() & geometry() is not the real size when app runs
-
Hi
size() & geometry() do report the real size
however , if you ask about sizes in the constructor
they might not be updated yet as some calculations
are cached until the showEvent to allow layout etc to
be up and running. -
@opengpu said in how to get the real size of the widget? the result return by the size() & geometry() is not the real size when app runs:
so how can i get the showed size in the constructor?
While constructor is being executed the widget is not yet shown, so it is simply impossible.
-
When app runs ?
What do you mean by this ? It helps if you show where are you trying to get the size ? You can use something like rect() also to get the size. As everybody said, you can't get the size unless it is shown.
-
-
@mpergand
Your suggestion is interesting. However, if the OP wants to go down this route I think he should look carefully at the comments in response to the "accepted solution" at https://stackoverflow.com/a/3996525/489865 (which is where I presume you got it from). They may also explain why you are seeing "odd behaviour" as per your "The issue is if then after you turn off this attribute, the show() method does nothing.". In the same thread https://stackoverflow.com/a/19235153/489865 appears to offer a more complex but "safer" mechanism for determining the size, I believe.