Important: Please read the Qt Code of Conduct -

Click with the mouse through a label

  • hello to the whole community Qt Forum,
    I would like to know if there is an option for qLabel that allows me to make it transparent only for the mouse, but in reality it must be seen; That is, this label contains a text, but I need to click below.
    I hope I was clear
    Thanks in advance :)

  • Moderators

    Yes, you just need to reimplement the mouse click event and set accepted property to false.

    Example for widgets:

    void MyLabel::mousePressEvent(QMouseEvent *event) {
    void MyLabel::mouseReleaseEvent(QMouseEvent *event) {

    QML example:

    Label {
      MouseArea {
        onClicked: mouse.accepted = false

    Brain-to-terminal, untested. But might work :-)

  • Lifetime Qt Champion


    IIRC, you can set the Qt::WA_TransparentForMouseEvents widget attribute and it should behave the way you'd like.

Log in to reply