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 Updated to NodeBB v4.3 + New Features

QML objects inside JavaScript in QML

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 291 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 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

    GrecKoG 1 Reply Last reply
    0
    • V Vijaykarthikeyan

      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

      GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on 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
      1
      • GrecKoG GrecKo

        @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 last edited by
        #3

        @GrecKo Thank you..it works

        1 Reply Last reply
        0
        • GrecKoG GrecKo

          @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 last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • V Vijaykarthikeyan has marked this topic as solved on

          • Login

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