Qt equivalent of JavaScript .charCodeAt()
Solved
General and Desktop
-
wrote on 9 Sept 2023, 16:10 last edited by
How to translate this code from JS to Qt:
const str = "你好"; const code = str.charCodeAt(0); console.log(code); // output: 20320
-
wrote on 9 Sept 2023, 16:44 last edited by 8Observer8 9 Sept 2023, 16:46
Solution:
QString str = "你好"; int code = str[0].unicode(); QHBoxLayout *hbox = new QHBoxLayout(this); QLabel *lbl = new QLabel(QString::number(code)); hbox->addWidget(lbl); setLayout(hbox);
-
1/2