0

I'm doing an interface with Qt5.5.

I have several Qlabel on a first UI and I have implemented mouseReleaseEvent to open a new UI when I click on the labels. This works. When I click on the labels, it do "emit clicked" and then the signal "clicked()" calls the slot "slotClicked()" and it open the new window.

My problem is: How can I know which label is clicked?

Because the window I want to open depends on which label is clicked.

Tomáš Fejfar
  • 11,129
  • 8
  • 54
  • 82
Clem's
  • 41
  • 1
  • 7
  • Are all the labels connected to the same slot? – owacoder Mar 08 '16 at 16:25
  • yes. I create a class "myLabel" who inherit from QLabel. So then I do `label1 = new myLabel();` and all my labels have the same signal/slot. – Clem's Mar 08 '16 at 16:53
  • In the class myLabel, I have the function `void myLabel::mouseReleaseEvent (QMouseEvent * Event) { emit clicked(); } ` We could may be write a condition `if(label1..)` in this fonction? – Clem's Mar 08 '16 at 17:08
  • I did not understand the QSignalMapper as in the question "Passing an argument to a slot" so I did differently : in the constructor of my labels, I create a variable "idLabel". When I create a new label, I change his idLabel and then use this one like this `if(idLabel == "...") { ... }. It works with 2 labels, I will see with more label.. – Clem's Mar 09 '16 at 17:02

0 Answers0