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 connect to MouseArea clicked() signal from C++
Qt 6.11 is out! See what's new in the release blog

How to connect to MouseArea clicked() signal from C++

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 1.3k 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.
  • H Offline
    H Offline
    HJPVVV
    wrote on last edited by
    #1

    I can connect to the clicked signal of the QML Button type like this:

    QObject::connect(button, SIGNAL(clicked()), this, SLOT(on_clicked()));
    

    How do I connect to the clicked(mouse) signal of the QML MouseArea type?

    J.HilkJ 1 Reply Last reply
    0
    • H HJPVVV

      I can connect to the clicked signal of the QML Button type like this:

      QObject::connect(button, SIGNAL(clicked()), this, SLOT(on_clicked()));
      

      How do I connect to the clicked(mouse) signal of the QML MouseArea type?

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @HJPVVV

      MouseArea {
         anchors.fill:parent
         onClicked:{
           console.log("Mouse Clicked: Do stuff here")
        }
      }
      

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      1
      • H Offline
        H Offline
        HJPVVV
        wrote on last edited by
        #3

        Sorry that I did not repeat the entire title in the question.
        Hereby I do that: How do I connect to the clicked(mouse) signal of the QML MouseArea type in C++?

        ODБOïO 1 Reply Last reply
        0
        • H HJPVVV

          Sorry that I did not repeat the entire title in the question.
          Hereby I do that: How do I connect to the clicked(mouse) signal of the QML MouseArea type in C++?

          ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by ODБOï
          #4

          @HJPVVV hi
          https://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html#connecting-to-qml-signals

          also see Overview - QML and C++ Integration

          be aware of this warning

          1 Reply Last reply
          4

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved