Results 1 to 3 of 3

Thread: Having trouble maximizing my window - It resizes too large

  1. #1
    Join Date
    Apr 2009
    Location
    www.JaminGrey.com
    Posts
    71
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Having trouble maximizing my window - It resizes too large

    I want my window to have four different modes:
    - Fullscreen
    - Maximized without a border (like fullscreen, but the taskbar is still visible)
    - Maximized
    - Windowed (non-resizable)

    Windowed works fine, and maximized without a border works fine, but regular maximized isn't working.

    Regular plain-vanilla Maximized is filling up the entire screen including under the taskbar.

    Here's a screenshot showing what I mean:

    screenshot.png
    (editted, to cut down on resolution by cutting out blank space)

    I've tried multiple different ways of setting maximized, including:
    Qt Code:
    1. QWidget::setWindowFlags(Qt::Window);
    2. QWidget::setWindowState(Qt::WindowActive, Qt::Maximized);
    To copy to clipboard, switch view to plain text mode 

    I also tried manually re-sizing it, and I tried using QWidget::showMaximized().

    Here's my current code:
    Qt Code:
    1. void MainWindow::_recalculateWindowSize()
    2. {
    3. //Undo any previous minimums and maximums.
    4. QWidget::setMinimumSize(0, 0);
    5. QWidget::setMaximumSize(1000000, 1000000);
    6.  
    7. //Choose what settings to use, depending on WindowMode.
    8. if(this->windowMode == Engine::WindowMode::Fullscreen)
    9. {
    10. QWidget::setWindowFlags(Qt::Window);
    11. QWidget::resize( qApp->desktop()->size() );
    12. QWidget::showFullScreen();
    13. }
    14. else if(this->windowMode == Engine::WindowMode::Multitask)
    15. {
    16. QWidget::setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
    17.  
    18. QRect desktopGeometry = qApp->desktop()->availableGeometry();
    19. QWidget::resize(desktopGeometry.size());
    20. QWidget::move(desktopGeometry.x(), desktopGeometry.y());
    21.  
    22. QWidget::setWindowState(Qt::WindowActive); //Qt::Maximized
    23. }
    24. else if(this->windowMode == Engine::WindowMode::Maximized)
    25. {
    26. QWidget::setWindowFlags(Qt::Window);
    27.  
    28. //QWidget::setGeometry(qApp->desktop()->availableGeometry());
    29. QWidget::showMaximized();
    30. }
    31. else //Engine::WindowMode::Windowed
    32. {
    33. WindowSize windowSize = this->_calculateWindowSizeWithEditor(this->requestedWindowSize);
    34.  
    35. QWidget::setWindowFlags(Qt::Window | Qt::WindowMinMaxButtonsHint);
    36.  
    37. QWidget::showNormal();
    38. QWidget::resize(windowSize.ToQSize());
    39. //QWidget::setFixedSize(windowSize.ToQSize());
    40.  
    41. QWidget::move(50, 50); //Temp, haven't cent
    42. }
    43.  
    44. QWidget::show(); //Have to 'show()' to apply the new setWindowState() state.
    45. QWidget::grabKeyboard(); //Just incase we accidentally lost focus during the transition.
    46. }
    To copy to clipboard, switch view to plain text mode 

    MainWindow private inherits QWidget (but brings QObject into the public interface), and has no parent.
    (Note: It's not a QMainWindow, if that matters. I have no QMainWindow, just a parentless QWidget)

    Any ideas what I'm doing wrong?

  2. #2
    Join Date
    Dec 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Having trouble maximizing my window - It resizes too large

    Hello, quick question concerning the screenshot, is the windows taskbar set to auto hide? sometimes when thats the case the full screen is calculated as the space underneath the taskbar.

  3. #3
    Join Date
    Apr 2009
    Location
    www.JaminGrey.com
    Posts
    71
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Having trouble maximizing my window - It resizes too large

    No, it's not set to autohide. If it was set to autohide, I'd like it to fill that taskbar space, but it's not set to that.

    Thanks for the good question, though. =)

Similar Threads

  1. Replies: 0
    Last Post: 11th September 2011, 12:19
  2. QMdiSubWindow maximizing problem
    By hgedek in forum Qt Programming
    Replies: 1
    Last Post: 7th September 2011, 23:19
  3. Replies: 4
    Last Post: 20th April 2011, 02:46
  4. Maximizing a widget
    By Max Yaffe in forum Qt Tools
    Replies: 3
    Last Post: 11th July 2007, 06:05
  5. maximizing own widget on parent
    By masoroso in forum Newbie
    Replies: 8
    Last Post: 21st April 2006, 17:12

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.