With QT C++ what are the ways to convert between an ascii integer and a string in both directions
Unsolved
General and Desktop
-
I am not talking about numbers I mean the actual ascii values. I have tried to do this:
string chr(int a) { string b; b = char(a); return b; }
and this:
apart = part.toStdString()[0]; val = int(apart)
I get this error:
mainwindow.obj:-1: error: LNK2019: unresolved external symbol "private: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl MainWindow::chr(int)" (?chr@MainWindow@@AEAA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function "public: __cdecl MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QEAA@PEAVQWidget@@@Z)
and
C:\Users\damon\Documents\QT\build-markov-Desktop_Qt_6_1_1_MSVC2019_64bit-Debug\debug\markov.exe:-1: error: LNK1120: 1 unresolved externals
I hate these error codes the most because they make the least amount of sense, but anyway?
-
@AI_Messiah said in With QT C++ what are the ways to convert between an ascii integer and a string in both directions:
unresolved external symbol
Your
chr()
is defined in header file as method of MainWindow, right? But in source file, you did not define it - it should read:string MainWindow::chr(int a)
numbers I mean the actual ascii values
But they are the same! ASCII table is just a bunch of numbers. Anyway, if you have an ASCII code, like
'A'
or65
, you can do this:const QString myCharacter(QChar(65)); qDebug() << myCharacter;
And to go the other way:
qDebug() << int(myCharacter.toLatin1().at(0));;