vendredi 18 janvier 2019

Connecting function to dynamically made QPushButton

Sorry, this question is probably duplicate but i have to ask since i can't make it work.

I am dynamically making QPushButtons with for loop like this.

 for (int var = 0; var < size; ++var) {
     QPushButton *copyr = new QPushButton("copy");
     ...
}

I am successfully adding those new widgets to layout but i cant bind an function on them.I am trying to connect that button on SLOT like as many sources on the internet had suggested:

connect (copyr , SIGNAL( clicked() ), this, SLOT( c2c(txt) ) );

but i can't make it work, and i am kp getting an error like :

No such SLOT ClassName::c2c(txt)

event it's normally defined in .h file and it exists in .cpp file also. Any ides why is this happening and how too fix it?

Aucun commentaire:

Enregistrer un commentaire