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. Can't resize window
Qt 6.11 is out! See what's new in the release blog

Can't resize window

Scheduled Pinned Locked Moved Solved General and Desktop
resize
7 Posts 2 Posters 9.7k 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.
  • A Offline
    A Offline
    AlaaM
    wrote on last edited by AlaaM
    #1

    I need to set a fixed size for my entire application (all screens will have the same size).
    Even if the content won't fit, I would want the window size to remain fixed (and maybe hide some content).
    I tried:

    setSizePolicy (QSizePolicy::Ignored, QSizePolicy::Ignored);
    setFixedSize(width,height);
    

    in my MainWindow.
    But it doesn't work. The window always fits the content.
    How do I resize it to a fixed width and height?

    • the widgets in the window are assigned dynamically
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Why not use the Fixed QSizePolicy ?

      Also, do you mean fix the size of the main widget or are you fixing the size of all the widgets of your application ?

      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
      • A Offline
        A Offline
        AlaaM
        wrote on last edited by AlaaM
        #3

        Thanks for the reply.
        I also tried Fixed QSizePolicy:

        setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
        setFixedSize(WINDOW_WIDTH,WINDOW_HEIGHT);
        

        I got the same result.
        And I need to fix the size of the window itself. Even if that mean hiding some buttons. Like this:
        http://i90.photobucket.com/albums/k274/alaa_137/Screenshot from 2015-12-21 113820_zpskxpktac4.png
        I need my layout to look as in this picture. As you can see here, Button 4 is hidden. I need it to be shown only when it gets focus (maybe I need to make my layout scrollable)

        Thanks

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

          Use a QScrollArea

          Where are you setting the fixed size ?

          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
          1
          • A Offline
            A Offline
            AlaaM
            wrote on last edited by AlaaM
            #5

            Thanks.
            QScrollArea along with stackedWidget->setGeometry(0,0,WINDOW_WIDTH,WINDOW_HEIGHT); and scrollArea->setFixedSize(WINDOW_WIDTH,WINDOW_HEIGHT); worked.

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

              Why set the stacked widget geometry ? Shouldn't the scroll area be enough ?

              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
              • A Offline
                A Offline
                AlaaM
                wrote on last edited by
                #7

                Just tried to remove that and the screen didn't look as I wanted. Maybe it's because not all my screens are scrollAreas ...

                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