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. How to mask a singal
Qt 6.11 is out! See what's new in the release blog

How to mask a singal

Scheduled Pinned Locked Moved QML and Qt Quick
12 Posts 4 Posters 4.2k 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.
  • S Offline
    S Offline
    sfjam
    wrote on last edited by
    #1

    for example:i have two singals,a click singal and a PressAndHold singal,when i deal with a singal how to mask another,thanks very much !

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Those are individual signals. So you can connect them to different slots. What would you need masking for then?

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sfjam
        wrote on last edited by
        #3

        in gridview,on the one hand i want to click a picture then display it in full screen,on the other hand i want use onPressAndHold:{}and onReleased{} to implement drag and drop to change picture's position,drag and drop do it well but onclick:{} can not implement!

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          Somehow you have managed already part of the signal-slot mechanism. You should try to post a small example highlighting your problem.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • T Offline
            T Offline
            thisisbhaskar
            wrote on last edited by
            #5

            I don't know if you can ignore the click() signal. You can ignore the handling of your code inside the onClicked: slot.

            Inside your onPressAndHold: , set a variable to tell that you got long press. And when you get onClicked: slot, check if onPressAndHold was handled with the help of the variable you are setting.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sfjam
              wrote on last edited by
              #6

              how to ignore onPressAndHold :{} in onClick:{}

              1 Reply Last reply
              0
              • S Offline
                S Offline
                sfjam
                wrote on last edited by
                #7

                the code is :

                @
                import QtQuick 1.0

                Rectangle {
                width: 800
                height: 420
                color: "#222222"
                Component {
                id: widgetdelegate
                Item {
                id:refer
                width: grid.cellWidth; height: grid.cellHeight
                Image {
                id: im
                source: portrait;
                anchors.centerIn: parent
                width: grid.cellWidth - 10; height: grid.cellHeight - 10
                smooth: true
                MouseArea{

                                  onClicked: {
                                    console.log("test")
                                }//here do not carry out
                            }
                            //fillMode: Image.PreserveAspectFit
                            Rectangle {
                                id: imRect
                                anchors.fill: parent; radius: 5
                                anchors.centerIn: parent
                                border.color: "#326487"; color: "transparent"; border.width: 6;
                                opacity: 0
                            }
                        }
                        Rectangle {
                            id: iWasHere
                            width: 20; height: 20; radius: 20
                            smooth: true
                            anchors.centerIn: parent
                            color: "white";
                            opacity: 0
                        }
                        states: [
                            State {
                                name: "inDrag"
                                when: index == grid.firstIndexDrag
                                PropertyChanges { target: iWasHere; opacity: 1 }
                                PropertyChanges { target: imRect; opacity: 1 }
                                PropertyChanges { target: im; parent: container }
                                PropertyChanges { target: im; width: (grid.cellWidth - 10) / 2 }
                                PropertyChanges { target: im; height: (grid.cellHeight - 10) / 2 }
                                PropertyChanges { target: im; anchors.centerIn: undefined }
                                PropertyChanges { target: im; x: coords.mouseX - im.width/2 }
                                PropertyChanges { target: im; y: coords.mouseY - im.height/2 }
                            }
                        ]
                        transitions: [
                            Transition { NumberAnimation { properties: "width, height, opacity"; duration: 300; easing.type: Easing.InOutQuad } }
                        ]
                    }
                }
                
                GridView {
                    property int firstIndexDrag: -1
                

                flow: GridView.TopToBottom
                id: grid
                x: 0; y: 0
                //interactive: false

                    //anchors.rightMargin: 200
                   // anchors.bottomMargin: 100
                    //anchors.leftMargin: 200
                    //anchors.topMargin: 100
                    anchors.fill: parent
                    cellWidth: parent.width/5; cellHeight: parent.height/3;
                
                    model: WidgetModel { id: widgetmodel }
                    delegate: widgetdelegate
                    Item {
                        id: container
                        anchors.fill: parent
                    }
                    MouseArea {
                        id: coords
                        anchors.fill: parent
                
                        onReleased: {
                            if (grid.firstIndexDrag != -1)
                             widgetmodel.move(grid.firstIndexDrag,grid.indexAt(mouseX, mouseY),1)
                            grid.firstIndexDrag = -1
                            grid.interactive=true
                        }
                        onPressAndHold:  {
                            console.log("the x and the y is")
                            console.log(coords.mouseX)
                            console.log(coords.mouseY)
                            grid.firstIndexDrag=grid.indexAt(mouseX, mouseY)
                            grid.interactive=false
                        }
                
                    }
                }
                

                }
                @

                [EDIT: code formatting, please wrap in @-tags, Volker]

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  koahnig
                  wrote on last edited by
                  #8

                  sfjam, you need to enclose your code with '@' characters. One at the start of your code list and one after the last line.

                  Like this here:
                  @
                  first line of code
                  second line of code
                  @

                  Vote the answer(s) that helped you to solve your issue(s)

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    sfjam
                    wrote on last edited by
                    #9

                    DELETED Post:

                    • removed code
                    • please check if some of the moderators has done it, before you repost
                    • if you need to format, edit your original post or comment, it has an edit link on the right, just below your username/avater
                    • do not just repost everything in a new comment

                    thanks, Volker

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      koahnig
                      wrote on last edited by
                      #10

                      Sorry, I am not of any help at all here. I am on Qt C++ only.

                      Vote the answer(s) that helped you to solve your issue(s)

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mbrasser
                        wrote on last edited by
                        #11

                        Hi,

                        The mouse parameter available in onClicked should have a wasHeld property that is set to true if there was a pressAndHold. e.g. you should be able to test this like:
                        @
                        onClicked: if (mouse.wasHeld) return;
                        @

                        From memory, for QtQuick 1.1 the behavior was slightly changed so that onClicked will not fire if the mouse event in onPressAndHold is accepted (which it is by default if onPressAndHold is specified).

                        Regards,
                        Michael

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          sfjam
                          wrote on last edited by
                          #12

                          onClicked will not fire if the mouse event in onPressAndHold is accepted (which it is by default if onPressAndHold is specified),
                          can we change this?

                          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