Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. I need a fixed aspect ratio top level window. Can someone help?
Qt 6.11 is out! See what's new in the release blog

I need a fixed aspect ratio top level window. Can someone help?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 833 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jeffery
    wrote on last edited by Jeffery
    #1

    Re: Fixed aspect ratio for a widget
    I used a QDockWidget as a floating window and tried to fix its aspect ratio (e.g 3:2). However I can't do that when I try to reimplement the heightForWidth in the widget/sizePolicy/Layout. Later on I had to use resize in the ResizeEvent. The side effect was the window triggered several ResizeEvent and the sizes of the widget changed several time before it finally finished. The ResizeEvent was invoked only AFTER the RESIZE was done.

    The better way should be to update the width or height according to the aspect ratio before the the actual resize event. However I can't find a solution.

    J 1 Reply Last reply
    0
    • J Jeffery

      Re: Fixed aspect ratio for a widget
      I used a QDockWidget as a floating window and tried to fix its aspect ratio (e.g 3:2). However I can't do that when I try to reimplement the heightForWidth in the widget/sizePolicy/Layout. Later on I had to use resize in the ResizeEvent. The side effect was the window triggered several ResizeEvent and the sizes of the widget changed several time before it finally finished. The ResizeEvent was invoked only AFTER the RESIZE was done.

      The better way should be to update the width or height according to the aspect ratio before the the actual resize event. However I can't find a solution.

      J Offline
      J Offline
      Jeffery
      wrote on last edited by
      #2

      At last I found a way to address the issue: use the nativeEvent() to monitor the Windows message WM_RESISING and update the rectangle of the window.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved