Slot default parameter generates error
Solved
General and Desktop
-
When i set first slot default parameter i get an error:
//OK void on_setId( QByteArray id ); void on_setId( QString id = QString("something")); //ERROR void on_setId( QByteArray id = QByteArray::fromStdString("something"); //<-- void on_setId( QString id = QString("something"));
Error:
\moc_rej006.cpp:314: error: call of overloaded 'on_setId()' is ambiguous case 34: _t->on_setId(); break; ^
Moc is creating some weird cases for (non existing) functions:
case 34: _t->on_setId(); break; case 35: _t->on_setId((*reinterpret_cast< QString(*)>(_a[1]))); break; case 36: _t->on_setId(); break;
I dont have
on_setId()
which takes no parameters...
Whats wrong with this one? I mean why setting default parameter generates this error? -
This is invalid C++.
If you now call on_setId() how should compiler know which of on_setId() it should call?
The compiler error says the same: \moc_rej006.cpp:314: error: call of overloaded 'on_setId()' is ambiguous -
Hi,
On a side note, there's no need to use fromStdString to initialize a QByteArray with a string.