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

Declare object variable

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 830 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.
  • E Offline
    E Offline
    Eligijus
    wrote on last edited by
    #1

    I'm using stackview I have declared component

    Component {
        id: dog
        Dog { }
     }
    

    I push new object to stack view like so

    stackView.push(dog)
    

    From documentation push method returns object - Item. in my case object is Dog and Dog has method test(txt). I want to call that method this works:

    var asd = stackView.push(dog)
    asd.test("ta")
    

    But is there a way to do something like this?

    Dog asd = stackView.push(dog)
    asd.test("ta")
    
    raven-worxR 1 Reply Last reply
    0
    • E Eligijus

      I'm using stackview I have declared component

      Component {
          id: dog
          Dog { }
       }
      

      I push new object to stack view like so

      stackView.push(dog)
      

      From documentation push method returns object - Item. in my case object is Dog and Dog has method test(txt). I want to call that method this works:

      var asd = stackView.push(dog)
      asd.test("ta")
      

      But is there a way to do something like this?

      Dog asd = stackView.push(dog)
      asd.test("ta")
      
      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Eligijus said in Declare object variable:

      But is there a way to do something like this?

      no, since that's the nature of JavaScript. It's not type-safe, so no need to declare an item-type of a variable.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      E 1 Reply Last reply
      0
      • raven-worxR raven-worx

        @Eligijus said in Declare object variable:

        But is there a way to do something like this?

        no, since that's the nature of JavaScript. It's not type-safe, so no need to declare an item-type of a variable.

        E Offline
        E Offline
        Eligijus
        wrote on last edited by
        #3

        @raven-worx In this case by using var autocomplete stops working is there a fix?

        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