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. Unable to assign [undefined] to int during customizing ScrollBar
Forum Updated to NodeBB v4.3 + New Features

Unable to assign [undefined] to int during customizing ScrollBar

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
17 Posts 6 Posters 1.5k 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.
  • sierdzioS sierdzio

    @Kamichanw Which line is 33?

    K Offline
    K Offline
    Kamichanw
    wrote on last edited by Kamichanw
    #5

    @Lahearle I've tried to define width, but it still didn't work. In fact, even I just set an empty rectangle as contentItem of ScrollBar, like this:

    contentItem: Rectangle {}
    

    The error occurred still occurred when I hovered the ScrollBar.

    L 1 Reply Last reply
    0
    • K Kamichanw

      @Lahearle I've tried to define width, but it still didn't work. In fact, even I just set an empty rectangle as contentItem of ScrollBar, like this:

      contentItem: Rectangle {}
      

      The error occurred still occurred when I hovered the ScrollBar.

      L Offline
      L Offline
      LS-KS
      wrote on last edited by
      #6

      @Kamichanw ScrollView is a Layout. So please try

      Layout.preferredWidth
      

      instead of width

      K 1 Reply Last reply
      0
      • L LS-KS

        @Kamichanw ScrollView is a Layout. So please try

        Layout.preferredWidth
        

        instead of width

        K Offline
        K Offline
        Kamichanw
        wrote on last edited by Kamichanw
        #7

        @LS-KS I cannot understand... The width we discussed earlier is the width of ScrollBar. And ScrollBar is assigned to ScrollBar.vertical which is a attached property of ScrollView. It shouldn't be a child item of ScrollView.

        What's more, when the Rectangle is assigned to contentItem, it doesn't have attached property named Layout.

        JonBJ L 2 Replies Last reply
        0
        • K Kamichanw

          @sierdzio I don't know. As you can see, the error message shows that error occurred in qrc:/qt-project.org/imports/QtQuick/Controls/Windows/ScrollBar.qml which is a qt internal file.

          sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #8

          @Kamichanw said in Unable to assign [undefined] to int during customizing ScrollBar:

          @sierdzio I don't know. As you can see, the error message shows that error occurred in qrc:/qt-project.org/imports/QtQuick/Controls/Windows/ScrollBar.qml which is a qt internal file.

          Well, but looking at it will tell you which property assignment has failed. Then you will know which object in your code is undefined.

          (Z(:^

          K 1 Reply Last reply
          0
          • K Kamichanw

            @LS-KS I cannot understand... The width we discussed earlier is the width of ScrollBar. And ScrollBar is assigned to ScrollBar.vertical which is a attached property of ScrollView. It shouldn't be a child item of ScrollView.

            What's more, when the Rectangle is assigned to contentItem, it doesn't have attached property named Layout.

            JonBJ Online
            JonBJ Online
            JonB
            wrote on last edited by
            #9

            @Kamichanw
            If you cannot track down which item it is in your code, maybe try commenting each one out till you find out?

            K 1 Reply Last reply
            0
            • K Kamichanw

              @LS-KS I cannot understand... The width we discussed earlier is the width of ScrollBar. And ScrollBar is assigned to ScrollBar.vertical which is a attached property of ScrollView. It shouldn't be a child item of ScrollView.

              What's more, when the Rectangle is assigned to contentItem, it doesn't have attached property named Layout.

              L Offline
              L Offline
              LS-KS
              wrote on last edited by
              #10

              @Kamichanw
              I never used that ScrollBar Item so I may be wrong.
              In general when you place something into a Layout object (like ScrollView) you can't use width and height but must use Layout -properties like preferredWidth etc.
              You used width in your calculations.

              K 1 Reply Last reply
              0
              • JonBJ JonB

                @Kamichanw
                If you cannot track down which item it is in your code, maybe try commenting each one out till you find out?

                K Offline
                K Offline
                Kamichanw
                wrote on last edited by
                #11

                @JonB Of course, I have tried this strategy. However, even I commented all code in Rectangle, the problem persists.

                1 Reply Last reply
                0
                • L LS-KS

                  @Kamichanw
                  I never used that ScrollBar Item so I may be wrong.
                  In general when you place something into a Layout object (like ScrollView) you can't use width and height but must use Layout -properties like preferredWidth etc.
                  You used width in your calculations.

                  K Offline
                  K Offline
                  Kamichanw
                  wrote on last edited by
                  #12

                  @LS-KS As you can see in qt doc, it uses width as well.

                  1 Reply Last reply
                  0
                  • sierdzioS sierdzio

                    @Kamichanw said in Unable to assign [undefined] to int during customizing ScrollBar:

                    @sierdzio I don't know. As you can see, the error message shows that error occurred in qrc:/qt-project.org/imports/QtQuick/Controls/Windows/ScrollBar.qml which is a qt internal file.

                    Well, but looking at it will tell you which property assignment has failed. Then you will know which object in your code is undefined.

                    K Offline
                    K Offline
                    Kamichanw
                    wrote on last edited by
                    #13

                    @sierdzio Yes, I hope to open that file as well, but when I click the hyperlink in QML debugger console, it shows that
                    b9f4aaa2-8905-4d8e-9c2a-70abbe86b193-image.png
                    I also tried to search ScrollBar.qml in qt source directory, but there are too many file named ScrollBar.qml so that I don't know where to start.

                    JonBJ 1 Reply Last reply
                    0
                    • K Kamichanw

                      @sierdzio Yes, I hope to open that file as well, but when I click the hyperlink in QML debugger console, it shows that
                      b9f4aaa2-8905-4d8e-9c2a-70abbe86b193-image.png
                      I also tried to search ScrollBar.qml in qt source directory, but there are too many file named ScrollBar.qml so that I don't know where to start.

                      JonBJ Online
                      JonBJ Online
                      JonB
                      wrote on last edited by
                      #14

                      @Kamichanw
                      Is there a directory something like QtQuick\Controls\Windows in the source tree? If so, how many ScrollBar.qml files are there in that directory?

                      1 Reply Last reply
                      0
                      • K Offline
                        K Offline
                        Kamichanw
                        wrote on last edited by
                        #15

                        Hey guys, I opened C:\Qt\6.4.2\Src\qtdeclarative\src\quickcontrols2\windows\ScrollBar.qml . I think it might be the correct ScrollBar.qml. The line 33 uses contentITem.transitionDuration. But I cannot set in my file directly.

                        NativeStyle.ScrollBar {
                                // Fade a hovered-looking version of the handle
                                // on top of the default handle when hovering it
                                x: contentItem.x
                                y: contentItem.y
                                z: 1
                                width: contentItem.width
                                height: contentItem.height
                                control: controlRoot
                                subControl: NativeStyle.ScrollBar.Handle
                                overrideState: NativeStyle.StyleItem.AlwaysHovered
                                opacity: controlRoot.hovered || control.pressed ? 1 : 0
                                visible: contentItem instanceof NativeStyle.StyleItem--
                                Behavior on opacity { NumberAnimation { duration: contentItem.transitionDuration } } // line 33
                            }
                        
                        GrecKoG 1 Reply Last reply
                        0
                        • K Kamichanw

                          Hey guys, I opened C:\Qt\6.4.2\Src\qtdeclarative\src\quickcontrols2\windows\ScrollBar.qml . I think it might be the correct ScrollBar.qml. The line 33 uses contentITem.transitionDuration. But I cannot set in my file directly.

                          NativeStyle.ScrollBar {
                                  // Fade a hovered-looking version of the handle
                                  // on top of the default handle when hovering it
                                  x: contentItem.x
                                  y: contentItem.y
                                  z: 1
                                  width: contentItem.width
                                  height: contentItem.height
                                  control: controlRoot
                                  subControl: NativeStyle.ScrollBar.Handle
                                  overrideState: NativeStyle.StyleItem.AlwaysHovered
                                  opacity: controlRoot.hovered || control.pressed ? 1 : 0
                                  visible: contentItem instanceof NativeStyle.StyleItem--
                                  Behavior on opacity { NumberAnimation { duration: contentItem.transitionDuration } } // line 33
                              }
                          
                          GrecKoG Offline
                          GrecKoG Offline
                          GrecKo
                          Qt Champions 2018
                          wrote on last edited by
                          #16

                          @Kamichanw You should not customize native styles.
                          https://www.youtube.com/watch?v=mImptIBmWW0&t=1179s

                          K 1 Reply Last reply
                          0
                          • GrecKoG GrecKo

                            @Kamichanw You should not customize native styles.
                            https://www.youtube.com/watch?v=mImptIBmWW0&t=1179s

                            K Offline
                            K Offline
                            Kamichanw
                            wrote on last edited by
                            #17

                            @GrecKo But how can I customize ScrollBar of ScrollView? Should I have to implement my own ScrollView?

                            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