Quoting a message in the stream referenced by @blueskin :
This is surprisingly hard to do. Most window systems do not allow an application to set limits on a window other than max and min, and that it can be fixed.
The most common way to do this is to trigger a resize from a resize event. This often leads to recursion problems or looks weird because the widget is resized in a way that the user did not request.
Since most window systems do not allow you to resize the main window accordingly, the best solution is often to limit the child widget, rather than the parent. One way to do this is with the class provided by libqxt.
libqxt supports child widget support with a specific aspect ratio through QxtLetterBoxWidget . @blueskin's answer gives one good try to accomplish what was originally requested.
If you are interested, I recommend that you read the source for the resizeWidget() function and observe the places it falls into. As a background, libqxt uses pimpl and qxt_d() gets in the private member.
source share