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 we set a varrible out of MouseArea in Window type or Image Type?
Forum Updated to NodeBB v4.3 + New Features

How we set a varrible out of MouseArea in Window type or Image Type?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 2 Posters 1.1k Views 2 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.
  • stackprogramerS Offline
    stackprogramerS Offline
    stackprogramer
    wrote on last edited by stackprogramer
    #1

    conetnt file.js

    //js source
    var varone;
    

    conetent file Qml

    import file.js as jlib
    Window{jlib.varone:1;
    
    }
    
    

    when i inspect with the below source it print undefined!!!!!1

     console.debug(jlib.varone);
    

    how can i solve my problem.thanks for reply.

    1 Reply Last reply
    0
    • benlauB Offline
      benlauB Offline
      benlau
      Qt Champions 2016
      wrote on last edited by
      #2

      Add ".pragma library" to your Javascript file, and you need to set via Javascript statement like "jlib.varone = 1"

      stackprogramerS 1 Reply Last reply
      0
      • benlauB benlau

        Add ".pragma library" to your Javascript file, and you need to set via Javascript statement like "jlib.varone = 1"

        stackprogramerS Offline
        stackprogramerS Offline
        stackprogramer
        wrote on last edited by
        #3

        @benlau i added ".pragma library" to it,(default has) when i write ".pragma library" the IDE show error.

        1 Reply Last reply
        0
        • benlauB Offline
          benlauB Offline
          benlau
          Qt Champions 2016
          wrote on last edited by
          #4

          @stackprogramer said:

          @benlau i added ".pragma library" to it,(default has) when i write ".pragma library" the IDE show error.

          No double quote.

          And I mean your QML statement is wrong. You need to set via Javascript statement.

          e.g

          Window {
            Component.onCompleted : {
              jlib.varone = 1;
            }
          }
          
          1 Reply Last reply
          1
          • stackprogramerS Offline
            stackprogramerS Offline
            stackprogramer
            wrote on last edited by stackprogramer
            #5

            i did n't use this method,now that i use it my problem was solved thanks for reply.

            Component.onCompleted:  {
                      
                   }
            
            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