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. How to use the date in QML files loaded by LOADER element in my main QML files
Forum Updated to NodeBB v4.3 + New Features

How to use the date in QML files loaded by LOADER element in my main QML files

Scheduled Pinned Locked Moved QML and Qt Quick
9 Posts 3 Posters 2.0k 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.
  • M Offline
    M Offline
    mageLuzdia
    wrote on last edited by
    #1

    anxious :(

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      If you mean "data" instead of "date" then you are looking for "item" property.
      @
      Loader {
      id: myLoader
      source: "someFile.qml"
      }

      // somewhere else in code
      myLoader.item.someProperty // will return the value of "someProperty"
      @

      (Z(:^

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mageLuzdia
        wrote on last edited by
        #3

        [quote author="sierdzio" date="1377087064"]If you mean "data" instead of "date" then you are looking for "item" property.
        @
        Loader {
        id: myLoader
        source: "someFile.qml"
        }

        // somewhere else in code
        myLoader.item.someProperty // will return the value of "someProperty"
        @[/quote]
        yes i know what you said and thank u. but now there is a listview element in B.qml and i wanna use the currentIndex property of listview element of b.qml in A.qml.so using "loader.item.***"can't achieve my goal.and we can't also use "loader.item.listview.currentindex"... am i clear?- -

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          No. Do you get any error messages? It really should work, but exact details depend on your setup.

          (Z(:^

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mageLuzdia
            wrote on last edited by
            #5

            [quote author="sierdzio" date="1377164039"]No. Do you get any error messages? It really should work, but exact details depend on your setup.[/quote]
            ...no error message.
            and in b.qml,the listview element is not the root item. so "myloader.item.currentIndex"can't work but "myloader.item.mylistview.currentIndex"is illegal...so i dont konw how to deal with it ...

            1 Reply Last reply
            0
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              So add an intermediate step:
              @
              // B.qml
              Item {
              property int currentIndex: 0

              ListView {
              id: mylistview
              currentIndex: parent.currentIndex
              }
              }
              @

              Anod now use myloader.item.currentIndex.

              (Z(:^

              1 Reply Last reply
              0
              • J Offline
                J Offline
                joykamma
                wrote on last edited by
                #7

                !http://www.izhcn.com/1.jpg(mainscreen)!
                !http://www.izhcn.com/2.jpg(button1)!
                !http://www.izhcn.com/3.jpg(button2)!

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mageLuzdia
                  wrote on last edited by
                  #8

                  [quote author="sierdzio" date="1377164777"]So add an intermediate step:
                  @
                  // B.qml
                  Item {
                  property int currentIndex: 0

                  ListView {
                  id: mylistview
                  currentIndex: parent.currentIndex
                  }
                  }
                  @

                  Anod now use myloader.item.currentIndex.[/quote]
                  ...this means inital a currentIndex to 0 and assign 0 to mylistview.currentIndex.when using"myloader.item.currentIndex",it==0

                  1 Reply Last reply
                  0
                  • sierdzioS Offline
                    sierdzioS Offline
                    sierdzio
                    Moderators
                    wrote on last edited by
                    #9

                    I don't understand you. With the code above, you can run this in your buttons:
                    @
                    onButton1Clicked: myloader.item.currentIndex = 3; // sets the index to 3

                    onButton2Clicked: myloader.item.currentIndex = 8; // sets the index to 8
                    @

                    (Z(:^

                    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