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. QML objects inside JavaScript in QML
Forum Update on Monday, May 27th 2025

QML objects inside JavaScript in QML

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 282 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.
  • V Offline
    V Offline
    Vijaykarthikeyan
    wrote on 17 Aug 2023, 08:46 last edited by Vijaykarthikeyan
    #1

    I tired to use QML anchoring function inside Javascript functions.But is doesn't work. It is for anchoring the item like rectangle with window so,it should resize according to the window dynamically.

    function clearAnchors(item)
            {
                item.anchors.left = undefined;
                        item.anchors.top = undefined;
                        item.anchors.right = undefined;
                        item.anchors.bottom = undefined;
                        item.anchors.horizontalCenter = undefined;
                        item.anchors.verticalCenter = undefined;
                        item.anchors.fill = undefined;
                        item.anchors.centerIn = undefined;
                        item.anchors.right = parent.right;
                        item.anchors.bottom = parent.bottom;
                    // ... repeat for other anchors if needed
                }
    

    when assignining to parent.bottom/parent.right,error hits saying like QQuickAnchorsLine not assigned with number

    G 1 Reply Last reply 17 Aug 2023, 10:03
    0
    • V Vijaykarthikeyan
      17 Aug 2023, 08:46

      I tired to use QML anchoring function inside Javascript functions.But is doesn't work. It is for anchoring the item like rectangle with window so,it should resize according to the window dynamically.

      function clearAnchors(item)
              {
                  item.anchors.left = undefined;
                          item.anchors.top = undefined;
                          item.anchors.right = undefined;
                          item.anchors.bottom = undefined;
                          item.anchors.horizontalCenter = undefined;
                          item.anchors.verticalCenter = undefined;
                          item.anchors.fill = undefined;
                          item.anchors.centerIn = undefined;
                          item.anchors.right = parent.right;
                          item.anchors.bottom = parent.bottom;
                      // ... repeat for other anchors if needed
                  }
      

      when assignining to parent.bottom/parent.right,error hits saying like QQuickAnchorsLine not assigned with number

      G Offline
      G Offline
      GrecKo
      Qt Champions 2018
      wrote on 17 Aug 2023, 10:03 last edited by
      #2

      @Vijaykarthikeyan parent.right isn't defined in this context. Try item.parent.right instead.

      But just doing item.anchors.fill = item.parent should be enough.

      V 2 Replies Last reply 17 Aug 2023, 10:40
      1
      • G GrecKo
        17 Aug 2023, 10:03

        @Vijaykarthikeyan parent.right isn't defined in this context. Try item.parent.right instead.

        But just doing item.anchors.fill = item.parent should be enough.

        V Offline
        V Offline
        Vijaykarthikeyan
        wrote on 17 Aug 2023, 10:40 last edited by
        #3

        @GrecKo Thank you..it works

        1 Reply Last reply
        0
        • G GrecKo
          17 Aug 2023, 10:03

          @Vijaykarthikeyan parent.right isn't defined in this context. Try item.parent.right instead.

          But just doing item.anchors.fill = item.parent should be enough.

          V Offline
          V Offline
          Vijaykarthikeyan
          wrote on 17 Aug 2023, 10:43 last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • V Vijaykarthikeyan has marked this topic as solved on 17 Aug 2023, 11:04

          1/4

          17 Aug 2023, 08:46

          • Login

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