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. How to keep the window maximized?
Forum Updated to NodeBB v4.3 + New Features

How to keep the window maximized?

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 3 Posters 4.4k 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.
  • R rick_nakano

    Hi.
    I want to keep the window maximized.
    It's ok to minimizing it.
    I tried as below:

    void MainWindow::resizeEvent(QResizeEvent* e)
    {
    showMaximized();
    }

    but this isn't smart and can't be minimized:(
    Is there any good way?

    A Offline
    A Offline
    ambershark
    wrote on last edited by ambershark
    #2

    @rick_nakano You could check when it is being resized if it is minimized or not, if not, then force maximize it, if it is then ignore the resize.

    Something like:

    if (!isMinimized())
       showMaximized();
    

    Haven't tested that but it seems like it would work.

    Another idea is instead of using maximize, figure out what the max size would be and force that geometry when the window is not minimized.

    Also, I don't know what you're developing but I find apps that try to control my preferences (like sizing) to be incredibly annoying and won't use them. So it's not a great idea to restrict your users unless you have a good reason.

    My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

    R 1 Reply Last reply
    1
    • A ambershark

      @rick_nakano You could check when it is being resized if it is minimized or not, if not, then force maximize it, if it is then ignore the resize.

      Something like:

      if (!isMinimized())
         showMaximized();
      

      Haven't tested that but it seems like it would work.

      Another idea is instead of using maximize, figure out what the max size would be and force that geometry when the window is not minimized.

      Also, I don't know what you're developing but I find apps that try to control my preferences (like sizing) to be incredibly annoying and won't use them. So it's not a great idea to restrict your users unless you have a good reason.

      R Offline
      R Offline
      rick_nakano
      wrote on last edited by
      #3

      @ambershark
      thanks:)
      I decided not to restrict the size as you said.

      A 1 Reply Last reply
      1
      • R rick_nakano

        @ambershark
        thanks:)
        I decided not to restrict the size as you said.

        A Offline
        A Offline
        ambershark
        wrote on last edited by
        #4

        @rick_nakano Good call, most users would really hate that. Qt is great at sizing widgets to fit and you can always set a minimum size that your GUI looks good with. I tend to use 800x600 or 1000x700 as my minimum sizes. Most people have at least 1024x768 resolutions now-a-days so I figure that should be fine. Gives me room to work with the GUI design too.

        My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

        R 1 Reply Last reply
        0
        • R rick_nakano

          Hi.
          I want to keep the window maximized.
          It's ok to minimizing it.
          I tried as below:

          void MainWindow::resizeEvent(QResizeEvent* e)
          {
          showMaximized();
          }

          but this isn't smart and can't be minimized:(
          Is there any good way?

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by
          #5

          @rick_nakano
          You want to allow the window to be minimized or maximized (e.g. via the window buttons), but not to be drag-resized to anything else, is that right?

          R 1 Reply Last reply
          0
          • A ambershark

            @rick_nakano Good call, most users would really hate that. Qt is great at sizing widgets to fit and you can always set a minimum size that your GUI looks good with. I tend to use 800x600 or 1000x700 as my minimum sizes. Most people have at least 1024x768 resolutions now-a-days so I figure that should be fine. Gives me room to work with the GUI design too.

            R Offline
            R Offline
            rick_nakano
            wrote on last edited by
            #6

            @ambershark
            thanx for explaining finely:)
            then,I'll use 1024×768.

            1 Reply Last reply
            0
            • JonBJ JonB

              @rick_nakano
              You want to allow the window to be minimized or maximized (e.g. via the window buttons), but not to be drag-resized to anything else, is that right?

              R Offline
              R Offline
              rick_nakano
              wrote on last edited by
              #7

              @JNBarchan
              it's right but now solved:)

              JonBJ 1 Reply Last reply
              0
              • R rick_nakano

                @JNBarchan
                it's right but now solved:)

                JonBJ Online
                JonBJ Online
                JonB
                wrote on last edited by
                #8

                @rick_nakano
                OK, so you've discovered mainWindow.setMinimumSize(1024, 768);, right?

                R 1 Reply Last reply
                3
                • JonBJ JonB

                  @rick_nakano
                  OK, so you've discovered mainWindow.setMinimumSize(1024, 768);, right?

                  R Offline
                  R Offline
                  rick_nakano
                  wrote on last edited by
                  #9

                  @JNBarchan
                  yes,I'll use it or setFixedSize(1024,768)

                  A 1 Reply Last reply
                  0
                  • R rick_nakano

                    @JNBarchan
                    yes,I'll use it or setFixedSize(1024,768)

                    A Offline
                    A Offline
                    ambershark
                    wrote on last edited by
                    #10

                    @rick_nakano No you want to use setMinimumSize like @JNBarchan suggested. Setting a fixed size forces the widget to that size only.

                    I would assume you want your gui resizeable, if not then set a fixed size, if so then use the minimum so you always have at least that size. :)

                    My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

                    1 Reply Last reply
                    1
                    • R Offline
                      R Offline
                      rick_nakano
                      wrote on last edited by rick_nakano
                      #11

                      @ambershark
                      hmm,my gui application may be suitable if its size is restricted.
                      I'll try both and then decide which to use:)

                      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