Results 1 to 12 of 12

Thread: Custom maximization

  1. #1
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Custom maximization

    Hi guys,

    I need to have a main window which can only maximize in height.
    The problem is that when I set a fixed width the maximize button is disabled.
    I need that button enabled to fit the window vertically in the screen.
    How to set a fixed width and still have a maximize button enabled?

    Thanks you
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  2. #2
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Custom maximization

    Any idea?
    To sum up, I would like to have a fixed width and the maximize button to fit the window in height on the screen.
    Thank you for any hints.

    Kacper
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

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

    Default Re: Custom maximization

    I don't think this is possible on Qt level. Maybe there is some hint you might pass to the window manager while creating a widget but I doubt that. You would probably have to use the native API for this. You can try emulating the effect by resizing the window to previous width after detecting maximization.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Custom maximization

    Or you can resize your window to limits on resizeEvent

  5. #5
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Custom maximization

    Yes, I have already tried working with the resizeEvent and maximization.

    Thank you for the hints.
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

  6. #6
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Custom maximization

    Ok,

    Last question:

    I can implement my own resizeEvent(..), but I can't call the resize() or setGeometry() in the event due to infinite recursion, am I right?
    Howto set the size in the resize event then?
    I can get the old size and new size, set old width and only update the height. But which method to use inside resizeEvent?

    Thank you
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

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

    Default Re: Custom maximization

    Quote Originally Posted by maverick_pol View Post
    I can implement my own resizeEvent(..), but I can't call the resize() or setGeometry() in the event due to infinite recursion, am I right?
    You can. Just have a stop condition - i.e. if you want to resize to a size that is already set, don't call resize().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Custom maximization

    would this make sense? I get a recursion here(resizeEvent body)

    Qt Code:
    1. QSize oldSize = event->oldSize();
    2. QSize newSize = event->size();
    3. if(oldSize!=newSize)
    4. {
    5. resize(oldSize.width(),newSize.height());
    6. event->accept();
    7. }
    8. event->ignore();
    To copy to clipboard, switch view to plain text mode 

    I am also looking for a signal to detect maximization. Is there any signal connected with this action? Should I overide the "showMaximixed()" slot in my mainwindow?
    How to detect the maximize action?

    THANK YOU
    Last edited by maverick_pol; 22nd May 2009 at 10:13.
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

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

    Default Re: Custom maximization

    Quote Originally Posted by maverick_pol View Post
    would this make sense?
    Not really. You have to calculate the new-new-size yourself and compare it to the new-size that you get from the event.


    I am also looking for a signal to detect maximization. Is there any signal connected with this action? Should I overide the "showMaximixed()" slot in my mainwindow?
    How to detect the maximize action?
    Yes, you can do that this way, but it will only work if someone calls showMaximized() and not when an appropriate button on the window's decoration is used.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    May 2007
    Location
    Lublin, Poland
    Posts
    345
    Thanks
    40
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Custom maximization

    Hi,

    Thank you for the detailed explaination. This is my last question:

    How to detect the maximize button click ?

    Thank you
    Qt allows you to use everything you want
    wysota
    --------------------------------------------------------------------------------
    #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
    abort(); // trap; generates core dump
    #else
    exit(1); // goodbye cruel world
    #endif

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

    Default Re: Custom maximization

    I guess you'd have to listen for native events but I can't guarantee there is one sent on each of the supported platforms.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #12
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Custom maximization

    You can override winEvent of your widget, and modify the size there.
    I remember seeing a code where they had done something like this. You will need to modify the MSG structure parameters

Similar Threads

  1. Custom Widget - First Steps
    By sekatsim in forum Qt Programming
    Replies: 8
    Last Post: 26th June 2008, 17:19
  2. Replies: 2
    Last Post: 16th May 2008, 14:39
  3. Custom widget
    By zorro68 in forum Qt Programming
    Replies: 7
    Last Post: 28th January 2008, 14:06
  4. Custom proxy model issue
    By Khal Drogo in forum Qt Programming
    Replies: 13
    Last Post: 30th November 2007, 12:41
  5. custom plug-in widget in another custom plug-in widget.
    By MrGarbage in forum Qt Programming
    Replies: 6
    Last Post: 27th August 2007, 15:38

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.