I have a problem with returning a const char*
from two functions from a class, by some reason the first value is a replica of the second value or some values is wrong, but both values returned are from different pointers, in this case two QMap
, the following is the code of the two functions:
const char* SomeClass::getSignal(QString signalName)
{
QString signalsignature = this->signals.value(signalName);
signalsignature.prepend(QString::number(QSIGNAL_CODE));
QByteArray ba = signalsignature.toLatin1(); // i try toUTF8 and to Local8Bit
const char* signalformated = ba.constData();
return signalformated;
}
const char* SomeClass::getSlot(QString slotName)
{
QString slotsignature = this->slots.value(slotName);
slotsignature.prepend(QString::number(QSLOT_CODE));
QByteArray ba = slotsignature.toLatin1();
const char* slotformated = ba.constData();
return slotformated;
}
The this->slot
and the this->signals
are QMap<QString, QString>
that save slots and signals signatures ( somesignal(int)
or someslot(bool)
with keys somesignal
, someslot
respectively).
The class that i use is loaded from a DLL by QLibrary
using an interface, all works fine using other functions from it, but using these functions like this:
const char* signal = someclassinstance->getSignal(tr("clicked"));
const char* slot = someclassinstance->getSlot(tr("onclicked"));
cout << "connecting signal " << signal << " to slot " << slot << endl;
this show me:
connecting signal clicked to slot rc
and the error when i use QObject::connect
Object::connect: Use the SLOT or SIGNAL macro to connect NovaRadioButton:: rc
I fill the QMap
s is some function with:
signals.insert(methodname,QString(metamethod.signature()));
I don't know what i am doing wrong or if maybe is a bug in Qt functions from QString
, thanks for your help.