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. QWidget:: close button hint
Forum Updated to NodeBB v4.3 + New Features

QWidget:: close button hint

Scheduled Pinned Locked Moved General and Desktop
11 Posts 6 Posters 11.4k Views 1 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.
  • V Offline
    V Offline
    veeeee_d
    wrote on 7 Dec 2011, 17:27 last edited by
    #2

    "This":http://doc.qt.nokia.com/4.7/widgets-windowflags.html example teaches you to use the window flags.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on 7 Dec 2011, 17:37 last edited by
      #3

      setWindowFlags sets all flags at once. You must do a bitwise or of all flags:

      @
      setWindowFlags(Qt::CustomizeWindowHint) | Qt::WindowCloseButtonHint);
      @

      Be aware that with that line, you reset every other flag!

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • H Offline
        H Offline
        haney
        wrote on 8 Dec 2011, 10:09 last edited by
        #4

        I tried @setWindowFlags(Qt::CustomizeWindowHint) | Qt::WindowCloseButtonHint);@ But it is not working in my case.

        In my mainwidget, I am adding Widget1 and Widget2 in a QVBoxLayout. Can a widget2 in a QVBoxLayout have a Close button hint as I needed.

        I need to have a closebutton for my Widget2, after adding it to a VBoxLayout. I am working on openSuSe 12.1 OS.

        Thanks..

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on 8 Dec 2011, 10:50 last edited by
          #5

          The close buttons (and the other elements settable by window flags) are for toplevel windows only. Most if not all of them do not have any influence on child widgets.

          So, the short story: no, you can't have a close button on a subwidget by setting a window flag.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • H Offline
            H Offline
            haney
            wrote on 8 Dec 2011, 11:34 last edited by
            #6

            Ok thanks for the info..

            I wrote a keypressevent for widget2 and catching Key_Escape and then hiding the widget.. Just a workaround..

            <CLOSED>

            Thanks..

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on 8 Dec 2011, 13:11 last edited by
              #7

              [quote author="haney" date="1323344057"]Ok thanks for the info..
              <CLOSED>
              [/quote]
              Closing of topics is only done when needed, and then by moderators or admins. So, topic is not closed. I am, however, glad it is [Solved] for you :-)

              1 Reply Last reply
              0
              • H Offline
                H Offline
                haney
                wrote on 16 May 2012, 11:21 last edited by
                #8

                Hi all,

                I need to have at least a small icon/button/action in my widget to have CLOSE button functionality. There should be some obvious symbol/icon for the user to understand that there is CLOSE option for my widget.

                Appreciate your help in this regard.

                Thanks,
                Haney.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on 16 May 2012, 11:26 last edited by
                  #9

                  [quote author="haney" date="1337167277"]Hi all,

                  I need to have at least a small icon/button/action in my widget to have CLOSE button functionality. There should be some obvious symbol/icon for the user to understand that there is CLOSE option for my widget.

                  Appreciate your help in this regard.

                  Thanks,
                  Haney.[/quote]

                  As you could have read in this topic already: there is no* support for providing close buttons/hints/options/whatevers for non-top-level widgets in Qt. If you want to provide that functionality, you will have to provide it.

                  *) Ok, perhaps there is some, like the close buttons on tabs, but not for the general case.

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    Poonam15
                    wrote on 8 Jun 2020, 08:34 last edited by
                    #10

                    Hi Haney,

                    You can use "close()" function simply by putting a push button and writing clicked slot for this button

                    J 1 Reply Last reply 8 Jun 2020, 09:55
                    0
                    • P Poonam15
                      8 Jun 2020, 08:34

                      Hi Haney,

                      You can use "close()" function simply by putting a push button and writing clicked slot for this button

                      J Online
                      J Online
                      JonB
                      wrote on 8 Jun 2020, 09:55 last edited by
                      #11

                      @Poonam15
                      You can, but this was not the OP's question from 2011, he wanted a window to have a close button on its title bar.

                      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