Hi,I haven't exactly understood the code you posted,however I tell you what I have understood.
//constructor of myMainForm...
connect(popup, SIGNAL(clicked()), this, SLOT(setOption()));
//constructor of myMainForm...
connect(popup, SIGNAL(clicked()), this, SLOT(setOption()));
To copy to clipboard, switch view to plain text mode
I suppose you want to use this single connection instead of the 8 connections for each button,is it right?
For what I know, it can't work because it's not the popup that emits the clicked() signal but are the buttons. If you want that your popup emits the clicked signal, you have to call it via a slot invoked by the clicked signal emitted from the buttons,:
//In the popup constructor
connect(buttonN,SIGNAL(clicked()),this,SLOT(emitclicked())); //8 times,for each button
//In the popup constructor
connect(buttonN,SIGNAL(clicked()),this,SLOT(emitclicked())); //8 times,for each button
To copy to clipboard, switch view to plain text mode
and then:
void Popup::emitclicked(){emit clicked();}
void Popup::emitclicked(){emit clicked();}
To copy to clipboard, switch view to plain text mode
Another way is to organize the buttons inside an array,in this way you can spare lines of code
//inside Mainform
QVector<Button*> buttons;
for(int i=0;i<8;i++){
buttons[i]=new Button(...);
connect(buttons[i],SIGNAL(clicked()),this,SLOT(setOption()));
//inside Mainform
QVector<Button*> buttons;
for(int i=0;i<8;i++){
buttons[i]=new Button(...);
connect(buttons[i],SIGNAL(clicked()),this,SLOT(setOption()));
To copy to clipboard, switch view to plain text mode
Bookmarks