I don't know what exactly goes wrong, but why don't you just use
QString nodeName;
To copy to clipboard, switch view to plain text mode
and
void setName(std::string name)
{
nodeName
= QString::fromStdString(name
);
}
void setName(std::string name)
{
nodeName = QString::fromStdString(name);
}
To copy to clipboard, switch view to plain text mode
or what would have my preference
void SomeClass
::setName(const QString &name
) {
nodeName = name;
}
void SomeClass::setName(const QString &name)
{
nodeName = name;
}
To copy to clipboard, switch view to plain text mode
then call the function using
obj.
setName(QString::fromStdString(somestring
));
obj.setName(QString::fromStdString(somestring));
To copy to clipboard, switch view to plain text mode
There is no need to use pointers for QStrings since they implement implicit sharing, which basically means that if you copy a string, you only copy a reference to the data. When you start to change the contents, then a deep copy is made. This design approach makes it easier for you to code, less error prone (less memory leaks) and more readable.
Bookmarks