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. How to hide the dialog window close button?
Forum Updated to NodeBB v4.3 + New Features

How to hide the dialog window close button?

Scheduled Pinned Locked Moved General and Desktop
12 Posts 7 Posters 47.6k Views 2 Watching
  • 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.
  • S Offline
    S Offline
    stukdev
    wrote on last edited by
    #2

    Have you try using the @void setWindowFlags ( Qt::WindowFlags type )@

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

      Its the correct function, the usage is the following:

      • "QWidget::setWindowFlags":http://doc.qt.nokia.com/latest/qwidget.html#windowFlags-prop
      • "Qt::WindowsFlags":http://doc.qt.nokia.com/latest/qt.html#WindowType-enum

      @
      MyDialog::MyDialog(QWidget* pParent) :
      QDialog(pParent, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint )
      {
      }
      @

      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
      • D Offline
        D Offline
        diegosarmentero
        wrote on last edited by
        #4

        I don't remember if you have any flag to dissable the close button, but in that scenario, you could apply the:
        Qt::FramelessWindow
        Flag in the initialization of the QDialog parent, and that will allow you to dismiss the NonClient Area (titlebar, the window borders), in that case you have to provide a way to close the window.

        Regards!

        Diego Sarmentero
        Blog: http://diegosarmentero.com.ar
        Twitter: http://twitter.com/diegosarmentero

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

          FramelessWindow removes the complete frame

          Qt::CustomizeWindowHint says: i say what to display. If you don't set Qt::WindowSystemMenuHint or Qt::WindowCloseButtonHint, the close button should be away but you have a title bar, window frame etc.

          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
          • D Offline
            D Offline
            deimos
            wrote on last edited by
            #6

            I think this removes only the close button

            @dialog->setWindowFlags( ( (dialog->windowFlags() | Qt::CustomizeWindowHint)
            & ~Qt::WindowCloseButtonHint) );@

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

              no it removes everything, also max and min button.
              windows flags does not contain min/m ax hint by default, as they are only needed if Qt::CustomizeWindowHint is used.

              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
              • Y Offline
                Y Offline
                yeaiping
                wrote on last edited by
                #8

                [quote author="Gerolf" date="1299145299"]Its the correct function, the usage is the following:

                • "QWidget::setWindowFlags":http://doc.qt.nokia.com/latest/qwidget.html#windowFlags-prop
                • "Qt::WindowsFlags":http://doc.qt.nokia.com/latest/qt.html#WindowType-enum

                @
                MyDialog::MyDialog(QWidget* pParent) :
                QDialog(pParent, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint )
                {
                }
                @[/quote]

                Thanks, your methods is fantancy. But's a little flaw. the Min button and Max button not hint.

                A smile is my sharp weapon (:

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

                  if you don't want m in/max button, remove them from the flas.

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

                  B 1 Reply Last reply
                  0
                  • Y Offline
                    Y Offline
                    yeaiping
                    wrote on last edited by
                    #10

                    [quote author="Gerolf" date="1299158166"]if you don't want m in/max button, remove them from the flas.[/quote]

                    Haha, yes. It's fine. Thanks all.

                    A smile is my sharp weapon (:

                    1 Reply Last reply
                    0
                    • G giesbert

                      if you don't want m in/max button, remove them from the flas.

                      B Offline
                      B Offline
                      Buller
                      wrote on last edited by
                      #11

                      @giesbert said in How to hide the dialog window close button?:

                      if you don't want m in/max button, remove them from the flas.

                      You mean like this?
                      : QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowTitleHint )
                      That does not work, the min/max buttons, i.e. the small arrows on the right hand side, are still there. I have tried various combinations of flags, but I cannot get rid of those arrows. I don't want to remove the top panel.

                      Pl45m4P 1 Reply Last reply
                      0
                      • B Buller

                        @giesbert said in How to hide the dialog window close button?:

                        if you don't want m in/max button, remove them from the flas.

                        You mean like this?
                        : QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowTitleHint )
                        That does not work, the min/max buttons, i.e. the small arrows on the right hand side, are still there. I have tried various combinations of flags, but I cannot get rid of those arrows. I don't want to remove the top panel.

                        Pl45m4P Offline
                        Pl45m4P Offline
                        Pl45m4
                        wrote on last edited by
                        #12

                        @Buller

                        This thread is 9 years old :)

                        Check out the QT Window Flag example:

                        https://doc.qt.io/qt-5/qtwidgets-widgets-windowflags-example.html


                        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                        ~E. W. Dijkstra

                        1 Reply Last reply
                        2

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved