Issue
I’m not really a C++ developer.
I’m trying to convert a double to local8Bit
for qDebug
.
Eg:
// This works because m_desc is a QString
qDebug("Description: " + m_desc.toLocal8Bit());
// This doesn't work because m_price is a double
qDebug("Price: " + m_price.toLocal8Bit());
How can I do this?
Solution
You are correct,
QString::toLocal8Bit
works on strings only.
Try QString::number
instead.
From the documentation:
QString::number(double n, char format = 'g', int precision = 6)
Example implementation:
qDebug() << QString::number(m_price);
Answered By – gortsu
Answer Checked By – Mary Flores (BugsFixing Volunteer)