Bonjour,

je suis en train de faire un petit widget pour comprendre le fonctionnement de C++/Qt. Je travaille sous Linux avec Netbeans 6.8.

Ce widget est en fait une sorte d'interface graphique personnelle pour ffmpeg. Les commandes sont stockées dans un fichier commands.xml qui est chargé par le widget.

J'ai donc créé 3 fichiers :
  • main.cpp

  • form.h

  • form.cpp


Le problème se situe au niveau d'un slot et je n'arrive pas à trouver la solution même en ayant torturé le problème dans tous les sens ...
Sur le click d'un QPushButton de mon interface j'obtiens le message suivant:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
Object::connect: No such slot form::encodeVideo(std::string fullpathApp2) in form.cpp:119
Voici mon main.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
 
#include <QApplication>
#include "form.h"
 
int main(int argc,char *argv[])
{
	// Get fullpath from arguments
	std::vector<const char*> v(argv, argv + argc);
	std::string fullpath = v[0];
	// Launch widget
	QApplication mainApplication(argc,argv);
	form mainForm(fullpath);
	mainForm.show();
	mainForm.setWindowIcon(QIcon("logo.png"));
	return mainApplication.exec();
}
Le form.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
#include <QObject>
#include <QString>
#include <QMessageBox>
#include <QFileDialog>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include "tinyxml.h"
#include "form.h"
 
 
const std::string textInfile = ("#infile");
const std::string textOutfile = ("#outfile");
const std::string textTime = ("#time");
const std::string idSd = ("sd");
const std::string idHd = ("hd");
const std::string idPv = ("pv");
 
 
form::form(std::string &fullpathApp):QWidget()
{
	std::string fullpathApp2 = fullpathApp;
 
	// Window properties
	setFixedSize(370,300);
	setWindowTitle("TYP");
 
	// Standard Definition section
	groupboxStandardDefinition = new QGroupBox(this);
	groupboxStandardDefinition->setTitle("Standard Definition");
	groupboxStandardDefinition->resize(350,80);
	groupboxStandardDefinition->move(10,10);
 
	labelStandardDefinition = new QLabel(groupboxStandardDefinition);
	labelStandardDefinition->setText("Select file");
	labelStandardDefinition->move(10,25);
 
	lineeditStandardDefinition = new QLineEdit(groupboxStandardDefinition);
	lineeditStandardDefinition->setReadOnly(true);
	lineeditStandardDefinition->resize(240,20);
	lineeditStandardDefinition->move(70,20);
 
	toolbuttonStandardDefinition = new QToolButton(groupboxStandardDefinition);
	toolbuttonStandardDefinition->setText("...");
	toolbuttonStandardDefinition->resize(20,20);
	toolbuttonStandardDefinition->move(320,20);
	QObject::connect(toolbuttonStandardDefinition,SIGNAL(clicked()),this,SLOT(openFile()));
 
	labelBasename = new QLabel(groupboxStandardDefinition);
	labelBasename->setText("Basename");
	labelBasename->move(10,55);
 
	lineeditBasename = new QLineEdit(groupboxStandardDefinition);
	lineeditBasename->resize(240,20);
	lineeditBasename->move(70,50);
 
	toolbuttonBasename = new QToolButton(groupboxStandardDefinition);
	toolbuttonBasename->setText(" ? ");
	toolbuttonBasename->resize(20,20);
	toolbuttonBasename->move(320,50);
	QObject::connect(toolbuttonBasename,SIGNAL(clicked()),this,SLOT(displayHelp()));
 
	// High Definition section
	groupboxHighDefinition = new QGroupBox(this);
	groupboxHighDefinition->setTitle("High Definition");
	groupboxHighDefinition->resize(350,50);
	groupboxHighDefinition->move(10,100);
 
	checkboxHighDefinition = new QCheckBox(groupboxHighDefinition);
	checkboxHighDefinition->setText("I wanna HD too !");
	checkboxHighDefinition->move(20,20);
 
	// Preview section
	groupboxPreview = new QGroupBox(this);
	groupboxPreview->setTitle("Preview");
	groupboxPreview->resize(350,70);
	groupboxPreview->move(10,160);
 
	checkboxPreview = new QCheckBox(groupboxPreview);
	checkboxPreview->setText("I wanna preview too !");
	checkboxPreview->move(20,20);
 
	labelPreviewAt = new QLabel(groupboxPreview);
	labelPreviewAt->setText("Preview at");
	labelPreviewAt->move(20,50);
 
	doublespinboxSeconds = new QDoubleSpinBox(groupboxPreview);
	doublespinboxSeconds->setMaximum(9999);
	doublespinboxSeconds->resize(60,20);
	doublespinboxSeconds->move(80,45);
 
	labelSeconds = new QLabel(groupboxPreview);
	labelSeconds->setText("seconds");
	labelSeconds->move(150,50);
 
	// Encode section
	progressbarEncode = new QProgressBar(this);
	progressbarEncode->setTextVisible(false);
	progressbarEncode->resize(220,15);
	progressbarEncode->move(20,255);
	progressbarEncode->setMinimum(0);
	progressbarEncode->setMaximum(100);
	//progressbarEncode->setVisible(false);
 
	pushbuttonEncode = new QPushButton(this);
	pushbuttonEncode->setText("Encode !");
	pushbuttonEncode->resize(90,30);
	pushbuttonEncode->move(270,245);
	QObject::connect(pushbuttonEncode,SIGNAL(clicked()),this,SLOT(encodeVideo(std::string fullpathApp2)));
 
	// Version section
	labelVersion = new QLabel(this);
	labelVersion->setText("vAlpha");
	labelVersion->move(4,289);
}
 
 
void form::openFile()
{
	// Select video file to encode
	QString fileName = QFileDialog::getOpenFileName(this,tr("Open File"),"/",tr("Video File(*.*)"));
	lineeditStandardDefinition->setText(fileName);
}
 
 
void form::displayHelp()
{
	// Display information message
	QMessageBox::information(this,"About Basename","Basename is used to generate filenames.\nFor example, if you enter \"typ\", output files should be named:\n\"typSD.flv\" \"typHD.flv\" and \"typPV.jpg\".");
}
 
 
void form::encodeVideo(std::string fullpathApp)
{
	TiXmlDocument fileXml("commands.xml");
	commands commandsEncode;
	command tempCommand;
 
	// Get values from form
	std::string fullpathFile = lineeditStandardDefinition->text().toStdString();
	std::string basename = lineeditBasename->text().toStdString();
	bool needHd = checkboxHighDefinition->isChecked();
	bool needPv = checkboxPreview->isChecked();
	double timePreview = doublespinboxSeconds->value();
 
	// Enable progress bar
	//progressbarEncode->setValue(0);
	//progressbarEncode->setVisible(true);
 
	// Check if a file has been selected
	if (fullpathFile.size() == 0)
		QMessageBox::critical(this,"Error","You must select a video file.");
	else
	{
 
		// Check if a basename has been entered
		if (basename.size() == 0)
			QMessageBox::critical(this,"Error","You must enter a basename.");
 
		// Form is correct
		else
		{			
 
			// Detect error in opening XML file
			if (!fileXml.LoadFile())
			{
				QMessageBox::critical(this,"Error","Unable to find the file \"commands.xml\".\nIt should be in the same folder as this application.");
			}
 
			else
			{
				TiXmlHandle commandHandle(&fileXml);
				TiXmlElement *commandElement = commandHandle.FirstChildElement().FirstChildElement().Element();
 
				// Detect error in finding first element in XML file
				if (!commandElement)
				{
					QMessageBox::critical(this,"Error","Unable to read XML data from the file \"commands.xml\".");
				}
 
				else
				{
					// Extract all fields from XML file
					while (commandElement)
					{
						tempCommand.name = commandElement->Attribute("name");
						tempCommand.id = commandElement->Attribute("id");
						tempCommand.pass = atoi(commandElement->Attribute("pass"));
						tempCommand.commandline = commandElement->GetText();
						// Save command in the appropriate list
						if (idSd.compare(tempCommand.id) == 0)
							commandsEncode.commandsSd.push_back(tempCommand);
						else if (idHd.compare(tempCommand.id) == 0)
							commandsEncode.commandsHd.push_back(tempCommand);
						else if (idPv.compare(tempCommand.id) == 0)
							commandsEncode.commandsPv.push_back(tempCommand);
						commandElement = commandElement->NextSiblingElement();
					}
 
					// Initialize encode parameters
					//std::string path = getPath(fullpathFile);
					int nbrCommandsSd = commandsEncode.commandsSd.size();
					int nbrCommandsHd = commandsEncode.commandsHd.size();
					int nbrCommandsPv = commandsEncode.commandsPv.size();
 
					// Encode SD
					for(int i=0;i<nbrCommandsSd;i++)
					{
						std::string currentCommandLine = commandsEncode.commandsSd[i].commandline;
						std::string updatedCommandLine = updateCommandVideo(currentCommandLine,fullpathFile,basename,textInfile,textOutfile,idSd);
						std::cout << updatedCommandLine << std::endl;
					}
 
					// Encode HD
					if (needHd)
					{
						for (int i = 0; i < nbrCommandsHd; i++)
						{
							std::string currentCommandLine = commandsEncode.commandsHd[i].commandline;
							std::string updatedCommandLine = updateCommandVideo(currentCommandLine,fullpathFile,basename,textInfile,textOutfile,idHd);
							std::cout << updatedCommandLine << std::endl;
						}
					}
 
					// Get preview
					if (needPv)
					{
						for (int i = 0; i < nbrCommandsPv; i++)
						{
							std::string currentCommandLine = commandsEncode.commandsPv[i].commandline;
							std::string updatedCommandLine = updateCommandPreview(currentCommandLine,fullpathFile,basename,timePreview,textInfile,textOutfile,textTime,idSd,idPv);
							std::cout << updatedCommandLine << std::endl;
						}
					}
 
 
				}
			}
		}
	}
}
 
 
std::string getPath(std::string filepath)
{
	int index = filepath.find_last_of("/\\");
	return filepath.substr(0,index+1);
}
 
 
std::string updateCommandVideo(std::string command,
						std::string fullpathIn,
						std::string filename,
						std::string tagInfile,
						std::string tagOutfile,
						std::string tag)
{
	// Initialize arguments
	std::string path = getPath(fullpathIn);
	std::transform(tag.begin(),tag.end(),tag.begin(),::toupper);   // To uppercase
	std::string fullpathOut = path + filename + tag;
 
	// Replace tags #infile and #outfile by fullpath
	int indexInfile = command.find(tagInfile);
	command.replace(indexInfile,tagInfile.length(),fullpathIn);
	int indexOutfile = command.find(tagOutfile);
	command.replace(indexOutfile,tagOutfile.length(),fullpathOut);
	return command;
}
 
 
std::string updateCommandPreview(std::string command,
						std::string fullpath,
						std::string filename,
						double time,
						std::string tagInfile,
						std::string tagOutfile,
						std::string tagTime,
						std::string tagSd,
						std::string tagPv)
{
	// Initialize arguments
	std::string path = getPath(fullpath);
	std::transform(tagSd.begin(),tagSd.end(),tagSd.begin(),::toupper);   // To uppercase
	std::string fullpathIn = path + filename + tagSd;
	std::transform(tagPv.begin(),tagPv.end(),tagPv.begin(),::toupper);   // To uppercase
	std::string fullpathOut = path + filename + tagPv;
	std::string timePreview;
	std::ostringstream temp;
	temp << time;                                                        // Double to String
	timePreview = temp.str();
 
	// Replace tags #infile #outfile and #time by fullpath
	int indexInfile = command.find(tagInfile);
	command.replace(indexInfile,tagInfile.length(),fullpathIn);
	int indexOutfile = command.find(tagOutfile);
	command.replace(indexOutfile,tagOutfile.length(),fullpathOut);
	int indexTime = command.find(tagTime);
	command.replace(indexTime,tagTime.length(),timePreview);
	return command;
}
Le form.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef _FORM_H
#define	_FORM_H
 
 
#include <QApplication>
#include <QWidget>
#include <QLabel>
#include <QLineEdit>
#include <QToolButton>
#include <QGroupBox>
#include <QCheckBox>
#include <QDoubleSpinBox>
#include <QProgressBar>
#include <QPushButton>
#include "commands.h"
 
 
class form : public QWidget
{
	// Use own slots
	Q_OBJECT
 
public:
	form(std::string &);
 
public slots:
	void openFile();
	void displayHelp();
	void encodeVideo(std::string fullpathApp);
 
private:
	// Standard Definition section
	QGroupBox *groupboxStandardDefinition;
	QLabel *labelStandardDefinition;
	QLineEdit *lineeditStandardDefinition;
	QToolButton *toolbuttonStandardDefinition;
	QLabel *labelBasename;
	QLineEdit *lineeditBasename;
	QToolButton *toolbuttonBasename;
	// High Definition section
	QGroupBox *groupboxHighDefinition;
	QCheckBox *checkboxHighDefinition;
	// Preview section
	QGroupBox *groupboxPreview;
	QCheckBox *checkboxPreview;
	QLabel *labelPreviewAt;
	QDoubleSpinBox *doublespinboxSeconds;
	QLabel *labelSeconds;
	// Encode section
	QProgressBar *progressbarEncode;
	QPushButton *pushbuttonEncode;
	// Version section
	QLabel *labelVersion;
};
 
 
std::string getPath(std::string);
 
 
std::string updateCommandVideo(std::string,
					 std::string,
					 std::string,
					 std::string,
					 std::string,
					 std::string);
 
 
std::string updateCommandPreview(std::string,
					std::string,
					std::string,
					double,
					std::string,
					std::string,
					std::string,
					std::string,
					std::string);
 
#endif
Globalement je souhaite obtenir le chemin de l'application et le transmettre à encodeVideo(). Si vous avez des remarques globales, des conseils à faire sur le code, je suis preneur !

Merci pour votre aide.