Bonjour,

Je développe une application, et à un moment donné, je fais une connexion SIGNAL / SLOT. Ce qui est particulier, c'est que j'ai créé une classe "mainFormController" qui contient certaines méthodes en plus qu'une connexion ... Je vous mets de façon raccourci la classe ainsi que la connexion :

mainFormController.h :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef MAINFORMCONTROLLER_H
#define MAINFORMCONTROLLER_H
 
#include <QObject>
#include "mainwindow.h"
#include <boost/scoped_ptr.hpp>
#include <string>
 
class mainFormController : public QObject
{
	Q_OBJECT
 
private:
	boost::scoped_ptr<mainWindow> mainWindowMem;
 
public:
	mainFormController(void);
	~mainFormController();
	void exec(void);
 
public slots:
	void modifyTerm(std::string language, std::string translation,int status,int length);
 
};
 
#endif // MAINFORMCONTROLLER_H
mainFormController.cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "mainFormController.h"
#include "mainwindow.h"
#include <string>
#include <QMessageBox>
 
 
using namespace std;
 
mainFormController::mainFormController(void)
{
	QObject::connect(
		mainWindowMem.get(),
		SIGNAL(termModified(string, string,int,int)),
		this,
		SLOT(modifyTerm(string, string,int,int)));
}
 
mainFormController::~mainFormController()
{
 
}
 
 
void mainFormController::exec(void)
{
	mainWindowMem->show();	
}
 
void mainFormController::modifyTerm(string language,string translation,int status,int length)
{
	QMessageBox msgBox;
	msgBox.setText(translation.c_str());
	msgBox.exec();
}
mainWindow.h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
 
#include <QtGui/QMainWindow>
#include "ui_mainwindow.h"
#include <boost/shared_ptr.hpp>
#include <string>
#include <map>
 
class mainWindow : public QMainWindow
{
	Q_OBJECT
 
public:
	mainWindow(QWidget *parent = 0, Qt::WFlags flags = 0);
	~mainWindow();
 
public slots:
void applyTermChange(void);
 
signals:
	void termModified(std::string language, std::string translation,int status,int length);
 
private:
	Ui::mainWindowClass ui;
	std::map<std::string,boost::shared_ptr<AQUIWidgetTermMessage>> listWidgetTermMessage;
};
 
#endif // MAINWINDOW_H
mainWindow.cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "mainwindow.h"
#include <qdesktopwidget.h>
#include "AQUIWidgetTermMessage.h"
#include <string>
#include <QFileDialog>
#include "XMLTermLoader.h"
#include "iTermLoader.h"
#include "termEngine.h"
#include <QMessageBox>
#include <set>
#include <vector>
#include "tinyxml.h"
#include <QCheckBox>
#include <boost/shared_ptr.hpp>
 
using namespace std;
 
mainWindow::mainWindow(QWidget *parent, Qt::WFlags flags)
	: QMainWindow(parent, flags)
{
	ui.setupUi(this);
 
	QObject::connect(
		ui.applyPushButton,
		SIGNAL(clicked()),
		this,
		SLOT(applyTermChange()));
}
 
mainWindow::~mainWindow()
{
	listWidgetTermMessage.clear();
}
 
void mainWindow::applyTermChange(void)
{
	map<string,boost::shared_ptr<AQUIWidgetTermMessage>>::iterator it;
	for(it=listWidgetTermMessage.begin();it != listWidgetTermMessage.end(); it++)
	{
		emit termModified((*it).second->getLabelLanguage()->text().toStdString(),(*it).second->getTextEditMessageLabel()->toHtml().toStdString(),0,20);
	}
}
Voilà, vous avez le code. Comme on peut le voir je fais la connexion du signal "termModifier" déclaré dans "mainWindow" dans "mainFormController". Et le slot "applyTermChange" du "mainWindow" doit émettre ce signal...

Souci, ça ne fonctionne pas :
Object::connect: No such signal mainWindow::termModified(string, string,int,int) in .\mainFormController.cpp:24
Object::connect: (sender name: 'mainWindowClass')
Merci par avance,
Cordialement,
Ero