Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Custom behavior for Drawer
QtWS25 Last Chance

Custom behavior for Drawer

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
quick controlsdrawer dragmarg
7 Posts 3 Posters 3.6k 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.
  • Camilo del RealC Offline
    Camilo del RealC Offline
    Camilo del Real
    wrote on last edited by
    #1

    Hi, I have an application with a StackView as main layout and a Drawer. I want the Drawer only be accessed when the StackView has only one component. According to QtQuick Controls 2's documentation I can do it setting the property dragMargin of Drawer to 0 or a less value. So I did this

    Drawer {
    id: drawer
    dragMargin: rootLayout.depth > 1 ? 0 : Qt.styleHints.startDragDistance
    ...
    }

    StackView {
    id: rootLayout
    ...
    }

    But does not work at all, because you can access dragging your finger from the edge of the phone. The only thing that achievement is to drastically reduce the area to get the Drawer.
    I appretiate the help, because I have a Page that insert into the StackView containing a SwipeView with content close to the edges and has conflicts with the Drawer that is not disabled. I tried setting 0 and -10 to dragMargin, but noting

    ? 1 Reply Last reply
    0
    • Camilo del RealC Camilo del Real

      Hi, I have an application with a StackView as main layout and a Drawer. I want the Drawer only be accessed when the StackView has only one component. According to QtQuick Controls 2's documentation I can do it setting the property dragMargin of Drawer to 0 or a less value. So I did this

      Drawer {
      id: drawer
      dragMargin: rootLayout.depth > 1 ? 0 : Qt.styleHints.startDragDistance
      ...
      }

      StackView {
      id: rootLayout
      ...
      }

      But does not work at all, because you can access dragging your finger from the edge of the phone. The only thing that achievement is to drastically reduce the area to get the Drawer.
      I appretiate the help, because I have a Page that insert into the StackView containing a SwipeView with content close to the edges and has conflicts with the Drawer that is not disabled. I tried setting 0 and -10 to dragMargin, but noting

      ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! How about disabling the Drawer?

      Drawer {
         id: drawer
         enabled: rootLayout.depth == 0
         onEnabledChanged: dragMargin = enabled ? Qt.styleHints.startDragDistance : 0
      }
      Camilo del RealC 1 Reply Last reply
      0
      • ? A Former User

        Hi! How about disabling the Drawer?

        Drawer {
           id: drawer
           enabled: rootLayout.depth == 0
           onEnabledChanged: dragMargin = enabled ? Qt.styleHints.startDragDistance : 0
        }
        Camilo del RealC Offline
        Camilo del RealC Offline
        Camilo del Real
        wrote on last edited by
        #3

        @Wieland
        The documentation and the compiler say that the property does not exist, which is strange because all components have always brought this property

        ? 1 Reply Last reply
        0
        • Camilo del RealC Camilo del Real

          @Wieland
          The documentation and the compiler say that the property does not exist, which is strange because all components have always brought this property

          ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          @Camilo-del-Real Oh, sry. Then maybe visible should do the same.

          Camilo del RealC 1 Reply Last reply
          0
          • ? A Former User

            @Camilo-del-Real Oh, sry. Then maybe visible should do the same.

            Camilo del RealC Offline
            Camilo del RealC Offline
            Camilo del Real
            wrote on last edited by
            #5

            @Wieland
            If I use

            Drawer {
            visible: appContentManager.depth == 1
            onVisibleChanged: dragMargin = visible ? Qt.styleHints.startDragDistance : 0
            }

            the drawer is always show at start up (it is not something to be) and with the treatment of onVisibleChanged the Drawer always has 0 in dragMargin when is hidden, which causes only be difficult to show it with draggind

            1 Reply Last reply
            0
            • jpnurmiJ Offline
              jpnurmiJ Offline
              jpnurmi
              wrote on last edited by
              #6

              If it's possible to drag a drawer open when it has drag margin set to 0, then please report a bug with appropriate details about the platform and device: https://bugreports.qt.io

              Camilo del RealC 1 Reply Last reply
              0
              • jpnurmiJ jpnurmi

                If it's possible to drag a drawer open when it has drag margin set to 0, then please report a bug with appropriate details about the platform and device: https://bugreports.qt.io

                Camilo del RealC Offline
                Camilo del RealC Offline
                Camilo del Real
                wrote on last edited by Camilo del Real
                #7

                @jpnurmi
                Well, I found a temporary solution while the original idea is fixed with dragMargin. Making the width is 0 can disable the Drawer, but only with the combination of width and dragMargin, if only use width, is still possible show a Drawer (an empty drawer)

                Drawer {
                        dragMargin: appContentManager.depth > 1 ? 0 : Qt.styleHints.startDragDistance
                        width: appContentManager.depth > 1 ? 0 : Math.min(appRoot.width, appRoot.height) / 3 * 2
                }
                

                I also report the bug
                https://bugreports.qt.io/browse/QTBUG-54629

                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