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] Disable min/max buttons on form
QtWS25 Last Chance

[SOLVED] Disable min/max buttons on form

Scheduled Pinned Locked Moved General and Desktop
11 Posts 4 Posters 12.4k Views
  • 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.
  • K Offline
    K Offline
    kalster
    wrote on last edited by
    #1

    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;
    }@

    1 Reply Last reply
    0
    • L Offline
      L Offline
      LinusA
      wrote on last edited by
      #2

      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...

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kalster
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          [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?

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kalster
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tobias.hunger
              wrote on last edited by
              #6

              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:-)

              1 Reply Last reply
              0
              • K Offline
                K Offline
                kalster
                wrote on last edited by
                #7

                thank you Tobias Hunger.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  giesbert
                  wrote on last edited by
                  #8

                  [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

                  Nokia Certified Qt Specialist.
                  Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    kalster
                    wrote on last edited by
                    #9

                    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?

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      LinusA
                      wrote on last edited by
                      #10

                      [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 .

                      1 Reply Last reply
                      0
                      • K Offline
                        K Offline
                        kalster
                        wrote on last edited by
                        #11

                        thank you LinusA. I marked this topic as solved.

                        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