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. [solved] javascript signals and slots
QtWS25 Last Chance

[solved] javascript signals and slots

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.1k 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.
  • G Offline
    G Offline
    gleach31
    wrote on last edited by
    #1

    Having trawled through all the docs, I find myself stuck again, mainly because I know javascript, but not C++

    What I have is :

    1 A load of buttons, dynamically created using javascript via createComponent("whatever.qml"), and the buttons all have onclicked pointing to a function do_something

    2 javascript arrays OUTSIDE the function full of stuff needed so that function do_something can make decisions.

    What I am trying to learn is...

    How does do_something find out what button got clicked ? (signals and slots I believe, but how in javascript ?)

    How does do_something, once it has somehow learnt what button got pressed, access those javascript arrays ? This seems to be a problem due to javascript global variables not being really really global in scope.

    Thanks in advance for any help. I suspect it's a situation where, once I am shown, it will all seem incredibly obvious.

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      If I understood you correctly, you can modify the do_something() to accept an argument (eg. do_something(objname) ) and then when you call the function from that particular Button Click you can pass the Button's objectName.

      157

      1 Reply Last reply
      0
      • G Offline
        G Offline
        gleach31
        wrote on last edited by
        #3

        Many thanks.

        And as predicted, it is one of those obvious solutions !

        I think in diving into the whole signal/slots aspect I forgot that onclicked calling a function can of course pass parameters.

        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