Adding QChar into a QString
-
wrote on 9 Feb 2023, 09:41 last edited by
-
@jsulm yes , QChar allows me to add bytes in hex which should be sent out as a single message, changing it to QString doesnot seem to help,
mSpeed and mAddress are both declared as QChar above...void MainWindow::writeSerial() { QString message; std::QString message = QChar(mSpeed) + QChar(mAddress); qDebug() << message; }
error: ‘QString’ is not a member of ‘std’; did you mean ‘wstring’?
88 | std::QString message = QChar(mSpeed) + QChar(mAddress);
| ^~~~~~~
| wstringLifetime Qt Championwrote on 9 Feb 2023, 11:10 last edited by jsulm 2 Sept 2023, 11:13@agmar said in Adding QChar into a QString:
void MainWindow::writeSerial()
{
QString message;
std::QString message = QChar(mSpeed) + QChar(mAddress);
qDebug() << message;}
Come on, it is self explanatory:
void MainWindow::writeSerial() { QString message = QChar(mSpeed) + QChar(mAddress); qDebug() << message; }
And I actually suggested:
void MainWindow::writeSerial() { QString message = QChar(mSpeed); message += QChar(mAddress); qDebug() << message; }
-
@agmar What should the result be if you add a char to a char?
First add mSpeed to the string and afterwards mAddress... -
@agmar What should the result be if you add a char to a char?
First add mSpeed to the string and afterwards mAddress...wrote on 9 Feb 2023, 09:48 last edited by@jsulm said in Adding QChar into a QString:
What should the result be if you add a char to a char?
That is a good question. What is the answer? :)
QChar
does not define a+
operator, I don't know what the "ambiguous" warning here is telling us? -
@jsulm said in Adding QChar into a QString:
What should the result be if you add a char to a char?
That is a good question. What is the answer? :)
QChar
does not define a+
operator, I don't know what the "ambiguous" warning here is telling us?@JonB Would be good to see the whole error message.
But as long as people post code and error messages as images (for whatever reason, it is way easier to copy paste text than creating and posting a screen shot) which are cut jsut where it becomes interesting... -
@JonB Would be good to see the whole error message.
But as long as people post code and error messages as images (for whatever reason, it is way easier to copy paste text than creating and posting a screen shot) which are cut jsut where it becomes interesting... -
@agmar Is there a reason why you use std::string and QChar?
Why don't you use QString?
Errors/warnings can be copied in the tab at the bottom. -
@agmar Is there a reason why you use std::string and QChar?
Why don't you use QString?
Errors/warnings can be copied in the tab at the bottom.wrote on 9 Feb 2023, 10:18 last edited by@jsulm yes , QChar allows me to add bytes in hex which should be sent out as a single message, changing it to QString doesnot seem to help,
mSpeed and mAddress are both declared as QChar above...void MainWindow::writeSerial() { QString message; std::QString message = QChar(mSpeed) + QChar(mAddress); qDebug() << message; }
error: ‘QString’ is not a member of ‘std’; did you mean ‘wstring’?
88 | std::QString message = QChar(mSpeed) + QChar(mAddress);
| ^~~~~~~
| wstring -
@jsulm yes , QChar allows me to add bytes in hex which should be sent out as a single message, changing it to QString doesnot seem to help,
mSpeed and mAddress are both declared as QChar above...void MainWindow::writeSerial() { QString message; std::QString message = QChar(mSpeed) + QChar(mAddress); qDebug() << message; }
error: ‘QString’ is not a member of ‘std’; did you mean ‘wstring’?
88 | std::QString message = QChar(mSpeed) + QChar(mAddress);
| ^~~~~~~
| wstringLifetime Qt Championwrote on 9 Feb 2023, 11:10 last edited by jsulm 2 Sept 2023, 11:13@agmar said in Adding QChar into a QString:
void MainWindow::writeSerial()
{
QString message;
std::QString message = QChar(mSpeed) + QChar(mAddress);
qDebug() << message;}
Come on, it is self explanatory:
void MainWindow::writeSerial() { QString message = QChar(mSpeed) + QChar(mAddress); qDebug() << message; }
And I actually suggested:
void MainWindow::writeSerial() { QString message = QChar(mSpeed); message += QChar(mAddress); qDebug() << message; }
-
@agmar said in Adding QChar into a QString:
void MainWindow::writeSerial()
{
QString message;
std::QString message = QChar(mSpeed) + QChar(mAddress);
qDebug() << message;}
Come on, it is self explanatory:
void MainWindow::writeSerial() { QString message = QChar(mSpeed) + QChar(mAddress); qDebug() << message; }
And I actually suggested:
void MainWindow::writeSerial() { QString message = QChar(mSpeed); message += QChar(mAddress); qDebug() << message; }
-
1/9