PDA

View Full Version : signal and slot passing data between a dialog and object, signal error



knobby67
14th August 2014, 16:40
Hi All,
hope you can help out with this. I'm trying to connect a signal from a dialog to a object slot except it's reporting and error “QObject::connect: No such signal GameAddDialog::add_to_game_list_signal( struct symbolstruct element_to_add ) in”

My dialog is show below



namespace Ui {
class GameAddDialog;
}
class GameAddDialog : public QDialog
{
Q_OBJECT

public:
explicit GameAddDialog(QWidget *parent = 0);
~GameAddDialog();
signals:
void add_to_Game_list_signal( struct Gamestruct element_to_add );
private slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
private:
Ui::GameAddDialog *ui;
};


my object is defined as


typedef struct Gamestruct
{
/*name of symbol*/
QString name_string;

}GAMESTRUCT;
class GameObject : public QObject
{
Q_OBJECT
public:
explicit GameObject(QObject *parent = 0);

signals:

public slots:
void add_to_Game_list_slot( struct Gamestruct element_to_add );
private:
std::vector <struct Gamestruct> Game_list;

};
extern class GameObject GameObjectClass;



I connect the signal and slot after int the function below after I create the dialog.


GameAddDialog mAddDialog;
/*connect the signals and slots*/
QObject::connect( &mAddDialog, SIGNAL( add_to_Game_list_signal( struct Gamestruct element_to_add ) ), &GameObjectClass, SLOT( add_to_Game_list_slot( struct Gamestruct element_to_add ) ) ); ***error line
mAddDialog.setModal( true );
mAddDialog.exec( );


The error occurs on the line Ive marked ***error.

Can anyone advise? Is it something to do with the GameAddDialog not being global

anda_skoa
14th August 2014, 17:08
You have argument names in your SIGNAL and SLOT macros, they only take the method's signature (method name and types of arguments).

Cheers,
_