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. Running onClicked [solved]
Forum Updated to NodeBB v4.3 + New Features

Running onClicked [solved]

Scheduled Pinned Locked Moved QML and Qt Quick
8 Posts 2 Posters 1.6k 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.
  • J Offline
    J Offline
    joanaguimas
    wrote on last edited by joanaguimas
    #1

    Hi! I'm doing a Qt Quick aplication for android, and I have a BluetoothDiscoveryModel, but I want that the bluetoothDiscoveryModel starts running just when I clicked on button, but I can't do this.. someone can help me?

    here's the piece of code that I want to change. I want: onClicked: top.state = "begin" and btModel.running = true..

    Button {
            id: but
            text: qsTr("Entrar")
            anchors.centerIn: parent
            onClicked: top.state == "begin";
        }
    

    //////////////////////////////////////////searchBox///////////////////////////////////////////////////////////////////////

         Search {
                id: searchBox
                opacity: 0;
                anchors.centerIn:parent; 
           }
    
         BluetoothDiscoveryModel {
             id: btModel
             running : true
    
             discoveryMode: BluetoothDiscoveryModel.MinimalServiceDiscovery
             onRunningChanged : {
                 if (!btModel.running && top.state == "begin" && !serviceFound) {
                     searchBox.animationRunning = false;
                     searchBox.appendText("\nNenhuma bicicleta encontrada. \n\nPor favor\nreinicie a aplicação.")
                 }
             }
             onServiceDiscovered: {
                 if (serviceFound)
                    return
                 serviceFound = true
                 console.log("Found new service " + service.deviceAddress + " " + service.deviceName + " " + service.serviceName);
                 searchBox.appendText("\nA conectar...")
                 remoteDeviceName = service.deviceName
                 socket.setService(service)
             }
             //uuidFilter: "e8e10f95-1a70-4b27-9ccf-02010264e9c8"
             remoteAddress: "00:12:06:01:59:08"
         }
    

    thanks

    Edited: Please use ``` to post code blocks - p3c0

    p3c0P 1 Reply Last reply
    0
    • J joanaguimas

      Hi! I'm doing a Qt Quick aplication for android, and I have a BluetoothDiscoveryModel, but I want that the bluetoothDiscoveryModel starts running just when I clicked on button, but I can't do this.. someone can help me?

      here's the piece of code that I want to change. I want: onClicked: top.state = "begin" and btModel.running = true..

      Button {
              id: but
              text: qsTr("Entrar")
              anchors.centerIn: parent
              onClicked: top.state == "begin";
          }
      

      //////////////////////////////////////////searchBox///////////////////////////////////////////////////////////////////////

           Search {
                  id: searchBox
                  opacity: 0;
                  anchors.centerIn:parent; 
             }
      
           BluetoothDiscoveryModel {
               id: btModel
               running : true
      
               discoveryMode: BluetoothDiscoveryModel.MinimalServiceDiscovery
               onRunningChanged : {
                   if (!btModel.running && top.state == "begin" && !serviceFound) {
                       searchBox.animationRunning = false;
                       searchBox.appendText("\nNenhuma bicicleta encontrada. \n\nPor favor\nreinicie a aplicação.")
                   }
               }
               onServiceDiscovered: {
                   if (serviceFound)
                      return
                   serviceFound = true
                   console.log("Found new service " + service.deviceAddress + " " + service.deviceName + " " + service.serviceName);
                   searchBox.appendText("\nA conectar...")
                   remoteDeviceName = service.deviceName
                   socket.setService(service)
               }
               //uuidFilter: "e8e10f95-1a70-4b27-9ccf-02010264e9c8"
               remoteAddress: "00:12:06:01:59:08"
           }
      

      thanks

      Edited: Please use ``` to post code blocks - p3c0

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @joanaguimas
      What is top ?

      157

      J 1 Reply Last reply
      0
      • p3c0P p3c0

        Hi @joanaguimas
        What is top ?

        J Offline
        J Offline
        joanaguimas
        wrote on last edited by
        #3

        @p3c0

        It's just the Id that I create for the begin..

        // Item {

          property string remoteDeviceName: ""
          property bool serviceFound: false
        
        id: top
        visible: true
        width: 640
        height: 480
        

        (...)

        p3c0P 1 Reply Last reply
        0
        • J joanaguimas

          @p3c0

          It's just the Id that I create for the begin..

          // Item {

            property string remoteDeviceName: ""
            property bool serviceFound: false
          
          id: top
          visible: true
          width: 640
          height: 480
          

          (...)

          p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @joanaguimas Ok. You can do this instead:

          onClicked: btModel.running = true
          

          157

          J 1 Reply Last reply
          0
          • p3c0P p3c0

            @joanaguimas Ok. You can do this instead:

            onClicked: btModel.running = true
            
            J Offline
            J Offline
            joanaguimas
            wrote on last edited by
            #5

            @p3c0 I just tried this one, but here, I put running: true, false or nothing?

            // BluetoothDiscoveryModel {

                 id: btModel
            
                 running : true
            
                 discoveryMode: BluetoothDiscoveryModel.MinimalServiceDiscovery
                 onRunningChanged : {
                     if (!btModel.running && top.state == "begin" && !serviceFound) {
                         searchBox.animationRunning = false;
                         searchBox.appendText("\nNenhuma bicicleta encontrada. \n\nPor favor\nreinicie a aplicação.")
                     }
            
            p3c0P 1 Reply Last reply
            0
            • J joanaguimas

              @p3c0 I just tried this one, but here, I put running: true, false or nothing?

              // BluetoothDiscoveryModel {

                   id: btModel
              
                   running : true
              
                   discoveryMode: BluetoothDiscoveryModel.MinimalServiceDiscovery
                   onRunningChanged : {
                       if (!btModel.running && top.state == "begin" && !serviceFound) {
                           searchBox.animationRunning = false;
                           searchBox.appendText("\nNenhuma bicicleta encontrada. \n\nPor favor\nreinicie a aplicação.")
                       }
              
              p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              @joanaguimas Put it false initially then onClicked set it to true.

              157

              J 1 Reply Last reply
              0
              • p3c0P p3c0

                @joanaguimas Put it false initially then onClicked set it to true.

                J Offline
                J Offline
                joanaguimas
                wrote on last edited by
                #7

                @p3c0 It worked! I had already tried and it had failed, maybe there was something wrong, but now works well!

                thank you!

                p3c0P 1 Reply Last reply
                0
                • J joanaguimas

                  @p3c0 It worked! I had already tried and it had failed, maybe there was something wrong, but now works well!

                  thank you!

                  p3c0P Offline
                  p3c0P Offline
                  p3c0
                  Moderators
                  wrote on last edited by
                  #8

                  @joanaguimas Congratulations :) Happy Coding..

                  157

                  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