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. [solved] (OSX) resizing the QMainWindow
Qt 6.11 is out! See what's new in the release blog

[solved] (OSX) resizing the QMainWindow

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.2k 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.
  • S Offline
    S Offline
    suizokukan
    wrote on last edited by
    #1

    I have a problem with a C++/Qt5 (Qt 5.4 on OSX) project, written for Linux but also tested on OSX (10.10.1). I have only encountered this error on OSX.

    When I start my program ("DipylonReader":https://github.com/suizokukan/dipylonreader), a window appears with the menu above and a window containing the infamous three icons red/orange/green, a toolbar and an empty widget : that's my QMainWindow.

    !http://94.23.197.37/hostedimages/1/screenshot1.png(DipylonReader on OSX : menu, tool bar, QMainWindow)!

    I if use the orange/green buttons, everything's works as expected.

    Now, I added an icon of my own to give a special size to the main window. Here's my code, triggered when the user presses this button :
    @
    void MainWindow::xyz__buttonPressed(void) {
    QSize size = QGuiApplication::primaryScreen()->size();
    size.setWidth(size.height()/2);
    size.setHeight(size.height());
    this->move((size.width() / 2), 0);
    this->resize(size);
    }@

    This code works well (the QMainWindow becomes smaller), except if the user has previously pressed the "green" icon, thus maximazing the QMainWindow. In this special case, the screen becomes black (no more main menu, no more desktop), the QMainWindow appears but not at the expected place :

    !http://94.23.197.37/hostedimages/1/screenshot2.png(QMainWindow on a black screen)!

    I tried to add the following line at the beginning of my function, without any success :
    @// leaving the full screen mode :
    this->showNormal();@

    I obviously doesn't understand how Qt works on OSX. Any help would be appreciated !

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      This:

      @void MainWindow::xyz__buttonPressed()
      {
      showNormal();
      QSize size = QGuiApplication::primaryScreen()->size();
      size.setWidth(size.height()/2);
      size.setHeight(size.height());
      this->move((size.width() / 2), 0);
      this->resize(size);
      }
      @

      works without an issue for me. Qt 5.3.2.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        suizokukan
        wrote on last edited by
        #3

        sandy.martel : thank you. I think I got it : the following line :
        @this->showNormal();@

        is mandatory, despite what I wrote previously. I tested my code with and without this line, which makes the difference.

        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