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. MainWindow not resizing when adding widgets

MainWindow not resizing when adding widgets

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 521 Views 2 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.
  • A Offline
    A Offline
    Athylus
    wrote on last edited by
    #1

    I have a QMainWindow that has a grid. The grid is not filled yet at (0, 1) and (0, 2). When a button click is performed, some images will be constructed inside in a QGraphicsView/Scene and they are added to a QHBoxLayout. This layout is then added to the grid at (0,1) and spans 2 columns and 1 row. However, my main window stays the size it currently is. But I want it to adapt to the size of the loaded images. How can I achieve this?

    P.S. I'm doing this in PyQt

    raven-worxR 1 Reply Last reply
    0
    • A Athylus

      I have a QMainWindow that has a grid. The grid is not filled yet at (0, 1) and (0, 2). When a button click is performed, some images will be constructed inside in a QGraphicsView/Scene and they are added to a QHBoxLayout. This layout is then added to the grid at (0,1) and spans 2 columns and 1 row. However, my main window stays the size it currently is. But I want it to adapt to the size of the loaded images. How can I achieve this?

      P.S. I'm doing this in PyQt

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Athylus
      try resizing it to it's sizeHint() after adding the widgets.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Athylus
        wrote on last edited by
        #3

        I tried gui.resize(gui.sizeHint()) but that only makes it smaller in the height. Now even less of the loaded image is showing.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Can you show how you are setting up your widgets ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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