hamza
hamza

Reputation: 2824

how to inherit a Qpushbutton signal

i passed an argument to a Qt Slot , the argument is a class that i have wroted ( Image_Viewer ).

to make connection betwen a signals and a slots , they both have to had the same type of argument ( correct me if i am wrong ).

i only need the clicked() signal of the Qpushbutton classe but since it has not the same argument of the Slot i have wroted , the connection cant be done.

if making another signal that also have (Image_Viewer) as an argument is the ONLY SOLUTION , then how and where can i wrote it ? and if it isnt then what is the solution ?

PS : Sorry for my english

Upvotes: 0

Views: 805

Answers (2)

Lwin Htoo Ko
Lwin Htoo Ko

Reputation: 2406

you can try by using an extra slot to call your slot.

connect(btn,SIGNAL(clicked()),this,SLOT(slotToCallYourRealSlot()));

void YourClass::slotToCallYourRealSlot()
{
   yourRealSlot(Image_Viewer());
}

void YourClass::yourRealSlot(Image_Viewer viewer)
{
   //your code
}

Upvotes: 1

Mat
Mat

Reputation: 206699

You could use a QSignalMapper to simulate "adding" a parameter to the clicked() slot. The example in the docs do just that.

More information in the Signals and Slots - Advanced Usage section.

Upvotes: 2

Related Questions