Results 1 to 10 of 10

Thread: Resizing a maximized, custom-frame window

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2006
    Location
    Austin, Texas, USA
    Posts
    18
    Qt products
    Qt3 Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: Resizing a maximized, custom-frame window

    Ok, this worked:

    Qt Code:
    1. showFullScreen();
    2. setGeometry(qApp->desktop()->availableGeometry());
    3. updateGeometry();
    To copy to clipboard, switch view to plain text mode 

    However, when you right-click on the application button in the Windows taskbar it doesn't have the "Restore" option highlighted... Is there any way to manually enable those options?

    Also, it would be a lot easier if I blocked the call for maximizing the application right when the application receives it and before any resize takes place; but for some reason I can't ignore the event. Here's the code I have in place that catches the maximize attempt:

    Qt Code:
    1. bool MyMainWindow::event(QEvent* e)
    2. {
    3. if(e->type() == QEvent::WindowStateChange && windowState() == Qt::WindowMaximized)
    4. {
    5. // Manually resize the GUI using the above method.
    6. e->ignore();
    7. return false;
    8. }
    9. else
    10. return QWidget::event(e);
    11. }
    To copy to clipboard, switch view to plain text mode 
    Even though I specify that the event should be ignored, the window still tries to maximize which causes a brief moment of window resizing up, then down, then back up to full-screen. Is there something else I need to do to ignore the event?

    Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Resizing a maximized, custom-frame window

    Quote Originally Posted by Claymore View Post
    However, when you right-click on the application button in the Windows taskbar it doesn't have the "Restore" option highlighted...
    Because it's not maximized. "Maximized" doesn't mean every situation when a widget fills the whole available space. Maximizing is done by the window manager and any change to the geometry causes the window to leave the maximized state.

    Is there any way to manually enable those options?
    I don't think so.

    Also, it would be a lot easier if I blocked the call for maximizing the application right when the application receives it and before any resize takes place; but for some reason I can't ignore the event.
    State change events are just a notification, they are spontaneous events.

    Even though I specify that the event should be ignored, the window still tries to maximize which causes a brief moment of window resizing up, then down, then back up to full-screen. Is there something else I need to do to ignore the event?
    I don't think you can ignore the event.

    Do you really need that "restore" option enabled? Can't you just have a button or something?

  3. #3
    Join Date
    Oct 2006
    Location
    Austin, Texas, USA
    Posts
    18
    Qt products
    Qt3 Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: Resizing a maximized, custom-frame window

    Do you really need that "restore" option enabled? Can't you just have a button or something?
    It's not so much my preference but more the preference of the customers involved, in this case a marketing department . I'll keep chugging away at this and see if I can't find some sort of solution. The reason why I think this should be possible (or at least I hope it is ) is that other applications such as Windows Media Player seem to use this similar method of hiding the window frame and masking off specific areas of the window, but somehow they can handle going to fullscreen just fine.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Resizing a maximized, custom-frame window

    Fullscreen or maximize? These two differ you know...

    And I think you don't have any problem maximizing the window and having "restore" enabled, the problem is you want to move the window then. Maybe try focusing on how to obtain the effect you need (whatever it is) without manipulating the geometry of the window once it is maximized?

  5. #5
    Join Date
    Oct 2006
    Location
    Austin, Texas, USA
    Posts
    18
    Qt products
    Qt3 Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: Resizing a maximized, custom-frame window

    You are correct - I meant maximized, not full screen (head's becoming frazzled from trying to get this working properly ).

  6. #6

    Default Re: Resizing a maximized, custom-frame window

    You could intercept win messages, overrride winEvent() in your window. This will let you set the width/height for system "maximize" function, so you could make it fullscreen.

    In the comments are provided links to msdn where you can read more about the MINMAXINFO structure and its variables.

    Qt Code:
    1. #include <windows.h>
    2.  
    3. bool MainWindow::winEvent ( MSG * message, long * result )
    4. {
    5. switch (message->message)
    6. {
    7. case WM_GETMINMAXINFO: {
    8.  
    9. // GetSysemMetrics(): http://msdn.microsoft.com/en-us/library/ms724385(VS.85).aspx
    10. // ptMinTrackSize - The minimum tracking width/height of a window, in pixels.
    11. // The user cannot drag the window frame to a size smaller than these dimensions.
    12. // ptMaxTrackSize - The default maximum width/height of a window that has a caption
    13. // and sizing borders, in pixels. This metric refers to the entire desktop. The user cannot
    14. // drag the window frame to a size larger than these dimensions.
    15.  
    16. // WM_GETMINMAXINFO: http://msdn.microsoft.com/en-us/library/ms632626(VS.85).aspx
    17. // MINMAXINFO structure: http://msdn.microsoft.com/en-us/library/ms632605(VS.85).aspx
    18.  
    19. MINMAXINFO *mmi = (MINMAXINFO*) (message->lParam);
    20.  
    21. QDesktopWidget desktopWidget;
    22. QRect desktop = desktopWidget.availableGeometry();
    23.  
    24. mmi->ptMaxSize.x = desktop.width();
    25. mmi->ptMaxSize.y = desktop.height();
    26.  
    27. mmi->ptMaxPosition.x = desktop.x();
    28. mmi->ptMaxPosition.y = desktop.y();
    29.  
    30. mmi->ptMinTrackSize.x = this->minWidth; // minimum width for your window
    31. mmi->ptMinTrackSize.y = this->minHeight; // minimum height for your window
    32.  
    33. mmi->ptMaxTrackSize.x = desktop.width();
    34. mmi->ptMaxTrackSize.y = desktop.height();
    35.  
    36. result = 0;
    37.  
    38. return true;
    39. break;
    40. }
    41. return false;
    42. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Main window with custom buttons ?
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2006, 06:32
  2. [QT4] Any way to disable window resizing ?
    By Amalsek in forum Qt Programming
    Replies: 5
    Last Post: 15th May 2006, 11:36
  3. Replies: 16
    Last Post: 7th March 2006, 15:57

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
  •  
Qt is a trademark of The Qt Company.