Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Convert QString to char
magda last edited by
How do I convert a QString to a char. When using latcardinalDirection = latlist.QLatin1Char(); the compiler says that QString does not have a member called QLatin1Char(). May you please assist?
char latcardinalDirection,longcardinalDirection ;
QString latitudestring = QInputDialog::getText(0, "Latitude"," Degrees Minutes Seconds Cardinal Direction: ",QLineEdit::Normal,"",&ok,0);
QStringList latlist; latlist = latitudestring.split(" "); int latdegrees = latlist.toInt(); int latminutes = latlist.toInt(); int latseconds = latlist.toInt(); latcardinalDirection = latlist.QLatin1Char();@
butterface last edited by
Normally the compiler is right saying a member is not existing if it is not.
If you are sure that the string is set correctly you can use something like
(Did not check const correctness on this)
QLatin1Char() is not a method it's a constructor (invalid in this case)
You can use e.g.
qxoz last edited by
As SGaist wrote "QLatin1Char() is not a method it’s a constructor"
in your case
is good solution. In future if you need char array or QByteArray you can use: