[SOLVED] Disable min/max buttons on form



  • I am trying to disable the min and max buttons on the dialog form. for some reason it is not working. what i am doing wrong?

    Dialog.cpp
    @#include "dialog.h"
    #include "ui_dialog.h"

    Dialog::Dialog(QWidget *Parent) :
    QDialog(Parent, Qt::CustomizeWindowHint |
    Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint ),
    ui(new Ui::Dialog)
    {
    ui->setupUi(this);
    }

    Dialog::~Dialog()
    {
    delete ui;
    }@



  • From the docs:
    [quote]
    Qt::CustomizeWindowHint
    Turns off the default window title hints.
    [/quote]
    [quote]
    Qt::WindowMinMaxButtonsHint
    Adds a minimize and a maximize button.
    [/quote]

    So without testing, I guess you'd have to call
    @
    Dialog::Dialog(QWidget *Parent) :
    QDialog(Parent, Qt::CustomizeWindowHint |
    Qt::WindowTitleHint ),
    ui(new Ui::Dialog)
    {
    ui->setupUi(this);
    }
    @
    to NOT show them...



  • yes, that works. thank you.
    I am just wondering why did the min/max code not work?



  • [quote author="kalster" date="1312242002"]yes, that works. thank you.
    I am just wondering why did the min/max code not work?[/quote]

    Which minMax code?

    @
    Dialog::Dialog(QWidget *Parent) :
    QDialog(Parent, Qt::CustomizeWindowHint |
    Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint ),
    @

    This adds the buttons explicit. Ar dpo you mean some other code?



  • I meant that my first post does not work and i am wondering why because i have Qt::WindowMinMaxButtonsHint in it but it does not disable the min/max buttons.


  • Moderators

    The window manager is free to ignore the hints requested by your application.

    So it could be that your code is working but ignored. I had that after playing too extensively with my window settings before. So especially on Linux it might be worth your while to check your settings:-)



  • thank you Tobias Hunger.



  • [quote author="kalster" date="1312267561"]I meant that my first post does not work and i am wondering why because i have Qt::WindowMinMaxButtonsHint in it but it does not disable the min/max buttons. [/quote]

    This flag does not disable the buttons, it just displays them



  • I should have said this sooner. running the following code disables the max but not the min button.

    @ QDialog(Parent, Qt::WindowMinMaxButtonsHint ),@

    yet, if i was to do the following then the close button is disabled but not the min/max buttons.

    @ QDialog(Parent, Qt::CustomizeWindowHint |
    Qt::WindowMinMaxButtonsHint ),@

    is there a bug in this code?



  • [quote author="kalster" date="1312270180"]I should have said this sooner. running the following code disables the max but not the min button.

    @ QDialog(Parent, Qt::WindowMinMaxButtonsHint ),@
    [/quote]
    Well, this is invalid usage of that flag. You cannot use it without CustomizeWindowHint. The docs say:
    [quote]
    The CustomizeWindowHint flag is used to enable customization of the window controls. This flag must be set to allow the WindowTitleHint, WindowSystemMenuHint, WindowMinimizeButtonHint, WindowMaximizeButtonHint and WindowCloseButtonHint flags to be changed.
    [/quote]

    [quote author="kalster" date="1312270180"]
    yet, if i was to do the following then the close button is disabled but not the min/max buttons.

    @ QDialog(Parent, Qt::CustomizeWindowHint |
    Qt::WindowMinMaxButtonsHint ),@

    is there a bug in this code?[/quote]
    No. Again, as was said before: You say to Qt: "disable everything, then turn on the min and max buttons". Of course this leaves the close button (hidden or disabled, Qt or the OS will decide). You didn't say you want the close button! That's what Qt::WindowCloseButtonHint is for.

    Read the bottom section of http://doc.qt.nokia.com/latest/qt.html#WindowType-enum .



  • thank you LinusA. I marked this topic as solved.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.