can i write a slots with defalut param?
General and Desktop
4
Posts
2
Posters
656
Views
2
Watching
-
wrote on 28 Mar 2015, 07:02 last edited by
i want to write a slot like this: void AddFile(const QStringList& list = QStringList());
and then i can do this:- connect(xxx, SIGNAL(add()), xxx, AddFile() );
- connect(xxx, SIGNAL(add(const QStringList&)), xxx, AddFile(const QStringList&));
is it Right?
ps. how to init a empty QStringList? what i wrote is right?
-
wrote on 28 Mar 2015, 07:49 last edited by
Hi,
In your header file
void AddFile(const QStringList &l = QStringList());
-
wrote on 28 Mar 2015, 09:34 last edited by
thank you , and i tried it seems work fine.
is it a good way to write like this? -
wrote on 28 Mar 2015, 09:42 last edited by
Yes,
is a C++ standard to define functions with default values for parameters.
In example you can define// You MUST provide _a but can omit _b and _c void f(int _a, int _b = 0, int _c = 1);
and you can call it
f(3), f(1, 2); f(4, 5, 6);
1/4