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. Qml Buttons and onClicked
Forum Updated to NodeBB v4.3 + New Features

Qml Buttons and onClicked

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

    Right now I have Qml code sending a signal to my c++ code that sends a true or false. When the button is clicked it sends a signal containing true. This is working how I want it to but I would like to send a false signal when the button is let go.

    So basically I am asking how you would send a true signal when the button is held down by the user and then send a false signal when the user lets go.

    I have looked into using states but I haven't found much information about them.

    Thanks for any help that can be offered. Below is my qml code.

    @import QtQuick 2.0
    import QtQuick.Window 2.0
    import QtQuick.Controls 1.0
    import QtQuick.Layouts 1.0
    import QtQuick.Dialogs 1.0
    import QtQuick.Particles 2.0

    Item {
    id: item
    width: 300; height: 300

    signal qmlSignal(bool msg)
    
    Rectangle {
        id: rectangle1
        x: 0
        y: 0
        width: 300
        height: 300
        color: "#c02323"
    
        Button {
            id: button1
            x: 0
            y: 0
            width: 300
            height: 300
            text: "button"
            onClicked: item.qmlSignal(true)
        }
        
    }
    

    }
    @

    1 Reply Last reply
    0
    • T Offline
      T Offline
      t3685
      wrote on last edited by
      #2

      You can use the signal handler

      @onPressedChanged@

      1 Reply Last reply
      0
      • K Offline
        K Offline
        koolbi
        wrote on last edited by
        #3

        I just made it a mouse area and used onPressed and onReleased

        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