在QLabels上显示整数? [英] Displaying Integers on QLabels?
本文介绍了在QLabels上显示整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
基本上,我正在制作一个简单的计算器程序来了解C ++ GUI的基础知识,但是我收到一条错误消息,导致我在 void MainWindow :: addx()
中具有以下代码行: label->setText(c);
并显示以下错误消息:
Basically i'm making a simple calculator program to understand the basics of C++ GUI however I get an error message leading to the line of code I have in the void MainWindow::addx()
to label -> setText(c);
with an error message of:
invalid user-defined conversion from 'int' to 'const QString&'[-fpermissive]
我真的不知道该错误消息意味着什么,我认为这意味着我不能在标签上显示整数.我只是想知道我是否可以在标签上显示整数,还是必须使用其他小部件.
I really don't know what that error message means I assume it means I cant display an integer on a label. I just wanted to know if I am able to display an integer on my label or do I have to use a different widget.
class MainWindow() {
int a, b, c;
QLabel * label;
...
};
void MainWindow::addx()
c = a + b;
label -> setText(c);
}
推荐答案
您必须将其转换:
firstnumberx();
secondnumberx();
c = a+b;
label->setText(QString::number(c));
这篇关于在QLabels上显示整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文