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 resize and snap frameless windows when drag to edges
Forum Updated to NodeBB v4.3 + New Features

How to resize and snap frameless windows when drag to edges

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 2 Posters 3.6k 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.
  • S Offline
    S Offline
    saeid0034
    wrote on last edited by saeid0034
    #1

    Hi, Im created a frameless windows with qt widget (im using this flags and Attribute to make it framless Qt::FramelessWindowHint and Qt::WA_TranslucentBackground )
    I want to know its possible to snap windows against other window and resize it when dragged to the edge of the screen like when we use normal window frame?
    I read about startSystemMove and startSystemResize in document, but im not sure how can i use it in qt widget

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      On win 10, it seems not to trigger if the window has no real titlebar -
      even if we drag it otherwise.

      It is possible with native api.
      https://forum.qt.io/topic/95542/enable-windows-autosize-function-on-frameless-qwidget/4

      S 1 Reply Last reply
      2
      • mrjjM mrjj

        Hi
        On win 10, it seems not to trigger if the window has no real titlebar -
        even if we drag it otherwise.

        It is possible with native api.
        https://forum.qt.io/topic/95542/enable-windows-autosize-function-on-frameless-qwidget/4

        S Offline
        S Offline
        saeid0034
        wrote on last edited by
        #3

        @mrjj thank you, I check it and yes looks like its working
        but sadly I dont have any Idea about how to use it on existing project (ui file created with qt designer) do you have any tips about it? thanks

        mrjjM 1 Reply Last reply
        0
        • S saeid0034

          @mrjj thank you, I check it and yes looks like its working
          but sadly I dont have any Idea about how to use it on existing project (ui file created with qt designer) do you have any tips about it? thanks

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @saeid0034
          Hi
          It wraps the actual widget so, on windows, you can use
          qwinwidget.cpp

          at line 128 where it says
          //Create the true app widget
          You can then instantiate your own widget and add to its layout. (m_Layout)

          S 1 Reply Last reply
          1
          • mrjjM mrjj

            @saeid0034
            Hi
            It wraps the actual widget so, on windows, you can use
            qwinwidget.cpp

            at line 128 where it says
            //Create the true app widget
            You can then instantiate your own widget and add to its layout. (m_Layout)

            S Offline
            S Offline
            saeid0034
            wrote on last edited by
            #5

            @mrjj sorry for late respond
            seems like its not usable in qt visual studio (qt6 visual studio 2019)
            framless window is ok but window is not draggable (its working in qt creator though)
            you have any Idea about it?

            mrjjM 1 Reply Last reply
            0
            • S saeid0034

              @mrjj sorry for late respond
              seems like its not usable in qt visual studio (qt6 visual studio 2019)
              framless window is ok but window is not draggable (its working in qt creator though)
              you have any Idea about it?

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @saeid0034
              Hi
              Sorry , i haven't tried it with Qt6.

              S 1 Reply Last reply
              1
              • mrjjM mrjj

                @saeid0034
                Hi
                Sorry , i haven't tried it with Qt6.

                S Offline
                S Offline
                saeid0034
                wrote on last edited by
                #7

                @mrjj In GitHub someone already fixed it
                https://github.com/dfct/TrueFramelessWindow/pull/19
                now window are resizable but still not draggable
                I think its because in original code they use QToolBar for draggable part of window, but I used a label...
                it should be ok but I dont know why its wont work

                1 Reply Last reply
                1
                • S Offline
                  S Offline
                  saeid0034
                  wrote on last edited by saeid0034
                  #8

                  my second problem was because of this code in nativeEvent

                  if (p_Widget->toolBar)
                  {
                          //If the mouse is over top of the toolbar area BUT is actually positioned over a child widget of the toolbar, 
                  	//Then we don't want to enable dragging. This allows for buttons in the toolbar, eg, a Maximize button, to keep the mouse interaction
                  	if (QApplication::widgetAt(QCursor::pos()) != p_Widget->toolBar)
                                      return false;
                  }
                  

                  by removing it now window are draggable, but this time it only work sometime (i mean I need to click on label multiple time to be able to drag it)

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    saeid0034
                    wrote on last edited by saeid0034
                    #9

                    after some searching I finaly found this and its working perfect
                    but still it have some minor problem like Minimize animation and Maximize animation dont show up (I don't know what is problem)

                    1 Reply Last reply
                    1

                    • Login

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