Convert String to Decimal and and vice versa,
-
I want to convert QString sValue = "A"; to Decimal = 65, and vice versa Decimal = 81, then QString = "Q"
QString sValue = "A"; bool bStatus = false; int nHex = sValue.toInt(&bStatus, 10); ui->info_2->setText(QString::number(nHex)); // Always return = 0
Can someone help me
Thanks ! -
I want to convert QString sValue = "A"; to Decimal = 65, and vice versa Decimal = 81, then QString = "Q"
QString sValue = "A"; bool bStatus = false; int nHex = sValue.toInt(&bStatus, 10); ui->info_2->setText(QString::number(nHex)); // Always return = 0
Can someone help me
Thanks !@DQUY05 said in Convert String to Decimal and and vice versa,:
10
16, not 10, your string is supposed to be hex interpreted, so 16
-
@DQUY05 said in Convert String to Decimal and and vice versa,:
10
16, not 10, your string is supposed to be hex interpreted, so 16
@J-Hilk , thank Sir !
I want to convert to Decimal not Hex, as you said that is not what I wantQString sValue = "A"; bool bStatus = false; int out = sValue.toInt(&bStatus, 16); ui->info_2->setText(QString::number(out)); // Always return = 10, I need it = 65, no need it = 10
Thanks !
-
I want to convert QString sValue = "A"; to Decimal = 65, and vice versa Decimal = 81, then QString = "Q"
QString sValue = "A"; bool bStatus = false; int nHex = sValue.toInt(&bStatus, 10); ui->info_2->setText(QString::number(nHex)); // Always return = 0
Can someone help me
Thanks ! -
@J-Hilk , thank Sir !
I want to convert to Decimal not Hex, as you said that is not what I wantQString sValue = "A"; bool bStatus = false; int out = sValue.toInt(&bStatus, 16); ui->info_2->setText(QString::number(out)); // Always return = 10, I need it = 65, no need it = 10
Thanks !
-
@J-Hilk Dear Sir !
As you said, I converted rightQString sValue = "A"; QChar out = sValue.at(0); ui->info_2->setText(QString::number(out.unicode(),10)); // return = 65 => OK
I still don't know how to do the opposite, something like this
int value=65; ui->info_2->setText(QString::fromUcs4(value)); // I need return = "A"
Thanks !
-
@J-Hilk Dear Sir !
As you said, I converted rightQString sValue = "A"; QChar out = sValue.at(0); ui->info_2->setText(QString::number(out.unicode(),10)); // return = 65 => OK
I still don't know how to do the opposite, something like this
int value=65; ui->info_2->setText(QString::fromUcs4(value)); // I need return = "A"
Thanks !
@DQUY05 said in Convert String to Decimal and and vice versa,:
I still don't know how to do the opposite,
int value=65; ui->info_2->setText(QString{QChar{value}});
-
@DQUY05 said in Convert String to Decimal and and vice versa,:
I still don't know how to do the opposite,
int value=65; ui->info_2->setText(QString{QChar{value}});
-
D DQUY05 has marked this topic as solved on