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. signal set from button on click, but not touch
Forum Updated to NodeBB v4.3 + New Features

signal set from button on click, but not touch

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 690 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.
  • I Offline
    I Offline
    igor_stravinsky
    wrote on last edited by igor_stravinsky
    #1

    Qt Quick Controls 2 5.11

    I've got a button that should send a signal to a parent view when clicked. Everything works as it should when clicked with a mouse, but when I tap the button on a touch screen (a Windows 10 surface) I can see that the onClicked() code is executed, but the slot for the signal never responds.

    Any idea why clicks would behave one way, but taps wouldn't?

    Drawer{
      id: myDrawer
    }
    
    Rectangle {
        id: root
        signal: mySignal()
    
        onMySignal:{
               myDrawer.open()
            }
    
         Item{
           Item{
             Button{
                  id:myButton
                  property int tapCount: 0;
                 onClicked: {
                        root.mySignal()
                        tapCount++;
                        myButton.text = tapCount;
                    }
           }
          }
        }
    }
    
    1 Reply Last reply
    0
    • I Offline
      I Offline
      igor_stravinsky
      wrote on last edited by igor_stravinsky
      #2

      Further testing shows that the signal is getting received by the onMySignal() handler, but that the call inside that handler to open a drawer isn't being called.

      I also can't change the opacity of an object outside the root rectangle hierarchy, so it's as if there's a scoping issue, and that from inside onMySignal(), I can't reference objects outside, but only when the button is touched.

      1 Reply Last reply
      0
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Qt Champions 2022
        wrote on last edited by
        #3

        Try providing the height and width for Drawer.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        I 1 Reply Last reply
        0
        • dheerendraD dheerendra

          Try providing the height and width for Drawer.

          I Offline
          I Offline
          igor_stravinsky
          wrote on last edited by
          #4

          @dheerendra
          I was trying to simplify the code. In reality myDrawer is a separate class that derives from a Drawer, and starts off like this:

          Drawer {
              id:root
              height:parent.height
              width:450
              dragMargin:0
              edge:Qt.RightEdge
              }
          

          And, as I mentioned, the drawer opens when the button is clicked on with a mouse, but not when tapped with a finger.

          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