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. really stupid question about Frameless
QtWS25 Last Chance

really stupid question about Frameless

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 3 Posters 2.3k 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.
  • GofferG Offline
    GofferG Offline
    Goffer
    wrote on last edited by
    #1

    Hello,

    Today I have a very stupid question... I want to redisplay the frame of a frameless window

    my Widget is a QPushButton (for test purpose)
    widget.setWindowFlags(QtCore.Qt.Widget | QtCore.Qt.FramelessWindowHint)

    now, i want to RE display the frame
    I ve tried this but it didn't do anything except closing the window...
    widget.setWindowFlags(widget.windowFlags() ^ QtCore.Qt.FramelessWindowHint)

    What is wrong with this ?

    Thx !

    Ni.SumiN 1 Reply Last reply
    0
    • GofferG Goffer

      Hello,

      Today I have a very stupid question... I want to redisplay the frame of a frameless window

      my Widget is a QPushButton (for test purpose)
      widget.setWindowFlags(QtCore.Qt.Widget | QtCore.Qt.FramelessWindowHint)

      now, i want to RE display the frame
      I ve tried this but it didn't do anything except closing the window...
      widget.setWindowFlags(widget.windowFlags() ^ QtCore.Qt.FramelessWindowHint)

      What is wrong with this ?

      Thx !

      Ni.SumiN Offline
      Ni.SumiN Offline
      Ni.Sumi
      wrote on last edited by
      #2

      @Goffer

      Just remove the setwindowFlags. You can get the frame back

      1 Reply Last reply
      0
      • GofferG Offline
        GofferG Offline
        Goffer
        wrote on last edited by
        #3

        What do you mean ?

        directly : widget.windowFlags() ^ QtCore.Qt.FramelessWindowHint ?? (it doesn't work)

        Ni.SumiN 1 Reply Last reply
        0
        • GofferG Goffer

          What do you mean ?

          directly : widget.windowFlags() ^ QtCore.Qt.FramelessWindowHint ?? (it doesn't work)

          Ni.SumiN Offline
          Ni.SumiN Offline
          Ni.Sumi
          wrote on last edited by Ni.Sumi
          #4

          @Goffer

          Oh No, not like that.
          I asked to remove the complete line
          setWindowFlags(QtCore.Qt.Widget | QtCore.Qt.FramelessWindowHint).
          //This line of code,. gives you frameless window. So remove it and you will have window with frame.

          Lets take an example:
          QDialog * dialog = new QDialog;
          dialog->setWindowFlags(setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog););
          // If you have this setwidnowFlag with FramlessWindowHint mean asking for //frames less Dialog.If you don't have this line mean , that you will have dialog with //default frame and hint icon ,m basing on your OS.

          ObjectName->setWindowsFlags(....) or directly in constructor setWindowsFlags(....) is used to specify the window-system properties of the widget. When you don't want change / specify window properties, then you don't need to set any windowFlags.

          1 Reply Last reply
          0
          • GofferG Offline
            GofferG Offline
            Goffer
            wrote on last edited by
            #5

            the thing is I am using the frameless when the mouse is moving and then when i release the mouse button I want to re display the frame. So I can't simply remove the line from my code ...

            Ni.SumiN 1 Reply Last reply
            0
            • GofferG Goffer

              the thing is I am using the frameless when the mouse is moving and then when i release the mouse button I want to re display the frame. So I can't simply remove the line from my code ...

              Ni.SumiN Offline
              Ni.SumiN Offline
              Ni.Sumi
              wrote on last edited by Ni.Sumi
              #6

              @Goffer

              Do I understand correctly ?
              So when you click mouse on the Dialog, it has to be framless and after the release of the mosue, again the dialog has to be with frame?
              Or
              Are you looking for any dragging frameless Dialog/widget ?

              1 Reply Last reply
              0
              • GofferG Offline
                GofferG Offline
                Goffer
                wrote on last edited by Goffer
                #7

                Yes, that's it
                The idea it to create a custom drag to take a widget out of the main window. So by setting its parent to None it automatically creates a frame around it that I am removing so i looks like the QDrag and then when i "drop" I want to re display the frame so it looks like a window.

                Ni.SumiN 1 Reply Last reply
                0
                • GofferG Goffer

                  Yes, that's it
                  The idea it to create a custom drag to take a widget out of the main window. So by setting its parent to None it automatically creates a frame around it that I am removing so i looks like the QDrag and then when i "drop" I want to re display the frame so it looks like a window.

                  Ni.SumiN Offline
                  Ni.SumiN Offline
                  Ni.Sumi
                  wrote on last edited by
                  #8

                  @Goffer

                  Well both you can do using the mouseEvents. See this sample code
                  https://forum.qt.io/topic/34354/solved-frameless-window-dragging-issue/3

                  1 Reply Last reply
                  0
                  • GofferG Offline
                    GofferG Offline
                    Goffer
                    wrote on last edited by
                    #9

                    The thing is I don t want to do that, for consistency purpose I want the window frame so it matches any other window style.

                    A solution would be on mouseReleaseEvent to create a new QWindow and parent the widget inside ...

                    1 Reply Last reply
                    0
                    • Chris KawaC Offline
                      Chris KawaC Offline
                      Chris Kawa
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      After you've changed window flags on a visible window you need to call show() again for the new setting to take effect. That's just how window managers work. It's documented here.

                      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