Displaying Integers on QLabels?

偶尔善良 提交于 2019-12-01 11:28:52

You have to convert it:

firstnumberx();
secondnumberx();
c = a+b;
label->setText(QString::number(c));

This should work..

label -> setText(QString::number(c));

If you need to add multiple number inside some string you can try below..

label -> setText(QString("%1").arg(c));
Kiribati

QLabel has setNum() methods taking int or double arguments:

label->setNum(c);

The setNum() methods format the supplied number and then set the text property with the formatted value. The documentation does not specify which locale is used for formatting, so you may wish to experiment.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!