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. Forcing an Aspect Ratio when resizing a main window frame

Forcing an Aspect Ratio when resizing a main window frame

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.1k 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.
  • R Offline
    R Offline
    ronM71
    wrote on last edited by
    #1

    I understand that in Qt4, there is no single flag you can set to have the mouse driven resizing of the window maintain a certain aspect ratio (say, 1:1). Is there a way to force a new size for the window while in "resizeEvent (QResizeEvent * event)"? the parameters of the event don't seem to support change or give the user a chance to inject a new size.

    My goal: GUI/Mouse resizing of a certain window frane will maintain its current aspect ratio, regardless of where you resize it from (sides, top, bottom, corners).

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      You should be able to use QSizePolicy::setHeightForWidth(true) + override QWidget::heightForWidth().

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      1 Reply Last reply
      0
      • R Offline
        R Offline
        ronM71
        wrote on last edited by
        #3

        Did it. my main window frame still re-sizes the same way, my virtual "heightForWidth()" isn't even called.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dangelog
          wrote on last edited by
          #4

          How are you doing it? And which OS/WM are you using? (Now that I reread those methods docs, they mention the equivalent counterparts in QLayoutItem... perhaps it's something good to investigate).

          Software Engineer
          KDAB (UK) Ltd., a KDAB Group company

          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