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. Fixing the ratio of width and height in the QMainWindow Component(PyQt 6.4)
Forum Updated to NodeBB v4.3 + New Features

Fixing the ratio of width and height in the QMainWindow Component(PyQt 6.4)

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 168 Views
  • 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.
  • S Offline
    S Offline
    ShinyangDevelop
    wrote on last edited by
    #1

    I was trying to makea window which has a ratio of 16:9, so I tried to use 'setHeightForWidth' and 'heightForWidth', but I failed. So is there anything that I can try? My main window code looks like this...

    class MainWindow(QMainWindow):
       def __init__(self):
           super().__init__()
           self.setWindowTitle("iPhone Reinforcement")
           monitor = None
           for m in get_monitors():
               if m.is_primary:
                   print(f'Monitor detected: {str(m)}')
                   monitor = m
                   break
    
           if monitor != None:
               print(str(m))
               self.resize(QSize(int(monitor.width/2), int(monitor.height/2)))
    
    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