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 maximize main window to full screen in Mac OSX and Windows OS ?
Forum Updated to NodeBB v4.3 + New Features

How to maximize main window to full screen in Mac OSX and Windows OS ?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 5.5k 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.
  • V Offline
    V Offline
    vsthakur1
    wrote on last edited by
    #1

    I am new to Qt. I am using Qt 4.8.3 library , Mac OSX 10.8 and windows 7.

    I have to fix the problem of maximizing the window to full screen when the user clicks on "Maximize" button on menu bar.

    I wanted to fix it within "mainwindow.ui" (rather than "ui_mainwindow.h" , only because it is generated code and all the changes made here will be lost in recompile). I tried playing around with the property "maximumSize" for main window.I tried to remove this property, set the values to "0" etc. - but nothing works on Mac OSX 10.8. Even I tried with generated file "ui_mainwindow.h" by commenting out "MainWindow->setMaximumSize()" but it did not work. I mean, the effect was, the main window simply disappeared and nothing visible on the screen.

    However, I found that for Windows (windows 7 and XP), if I commented out "MainWindow->setMaximumSize()" , it worked as desired.

    My question is - how can I maximize the main window to full screen for Mac OSX and Windows , preferably using mainwindow.ui and not from "ui_mainwindow.h"?

    1 Reply Last reply
    0
    • podsvirovP Offline
      podsvirovP Offline
      podsvirov
      wrote on last edited by
      #2

      You will likely need methods (slots) like show *:

      @
      void QWidget::show()
      void QWidget::showFullScreen()
      void QWidget::showMaximized()
      void QWidget::showMinimized()
      void QWidget::showNormal()
      @

      You worked with them?

      1 Reply Last reply
      0
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #3

        I don't exactly know what is the problem. Why do you ask for guidance on maximizing the window, but are trying to set the max size to 0? By default, sizing policy if set to be flexible, and ma window size is set to a huge number (I don't remember exactly how big it was).

        Or maybe you want to start the app maximized? Then you can use the method "QWidget::showMaximized()":http://qt-project.org/doc/qt-4.8/qwidget.html#showMaximized in your code.

        (Z(:^

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vsthakur1
          wrote on last edited by
          #4

          Thank you Konatatin. No , I have never worked with them.May I get any link for sample code /examples for these methods ? The key is , it should work both on Windows and Mac . I do not mind having two separate code for these platforms, if required.

          Many, many thanks Sierdzio for reply. The problem is, when I click on "maximize" icon, the size should be set to full screen.That, I want to do preferably using "mainwindow.ui" and not by any modification in generated file "ui_mainwindow.h”. You said, if the "sizing policy" is set to "default" and window size is set toa huge number , it should work oth for Windows and Mac? Surely, it is worth trying.
          I don't want the app to star maximized. But it should respond to "maximize" icon click and set to full screen.

          1 Reply Last reply
          0
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            As long as you don't set size policy to "Fixed" it should work well on all platforms. Please be aware, though, that Mac platform does not work as sane people expect it to - the maximize button does not work the same way as on Linux or Windows. Check with other apps - you will not get it to maximize under every circumstance.

            And BTW. it is never required to modify anything in generated "ui_*" files. Everything can be done in .ui or c++ behind it.

            (Z(:^

            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