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

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.
  • C Offline
    C Offline
    Camilo del Real
    wrote on 7 Jul 2016, 13:08 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 7 Jul 2016, 13:23
    0
    • C Camilo del Real
      7 Jul 2016, 13:08

      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 7 Jul 2016, 13:23 last edited by
      #2

      Hi! How about disabling the Drawer?

      Drawer {
         id: drawer
         enabled: rootLayout.depth == 0
         onEnabledChanged: dragMargin = enabled ? Qt.styleHints.startDragDistance : 0
      }
      C 1 Reply Last reply 7 Jul 2016, 13:55
      0
      • ? A Former User
        7 Jul 2016, 13:23

        Hi! How about disabling the Drawer?

        Drawer {
           id: drawer
           enabled: rootLayout.depth == 0
           onEnabledChanged: dragMargin = enabled ? Qt.styleHints.startDragDistance : 0
        }
        C Offline
        C Offline
        Camilo del Real
        wrote on 7 Jul 2016, 13:55 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 7 Jul 2016, 13:59
        0
        • C Camilo del Real
          7 Jul 2016, 13:55

          @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 7 Jul 2016, 13:59 last edited by
          #4

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

          C 1 Reply Last reply 7 Jul 2016, 14:25
          0
          • ? A Former User
            7 Jul 2016, 13:59

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

            C Offline
            C Offline
            Camilo del Real
            wrote on 7 Jul 2016, 14:25 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
            • J Offline
              J Offline
              jpnurmi
              wrote on 7 Jul 2016, 15:06 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

              C 1 Reply Last reply 7 Jul 2016, 16:48
              0
              • J jpnurmi
                7 Jul 2016, 15:06

                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

                C Offline
                C Offline
                Camilo del Real
                wrote on 7 Jul 2016, 16:48 last edited by Camilo del Real 7 Jul 2016, 16:49
                #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

                1/7

                7 Jul 2016, 13:08

                • Login

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