黑莓10中的CALC代码
CALC code in blackberry 10
我们如何在bb10中追加这两个字符串???我想为黑莓做一个计算器,但有一些错误。
请帮帮我。
我在这个代码中出错:
void CalcTrial::oneButtonClicked()
{
// Change the button text when clicked
if(textf==NULL)
{
textf->setText("1");
}
else
{
textf->QString+"1";
}
}
void CalcTrial::twoButtonClicked()
{
if(textf==NULL)
{
textf->setText("2");
}
else
{
textf->QString+"2";
}
}
void CalcTrial::threeButtonClicked()
{
if(textf==NULL)
{
textf->setText("3");
}
else
{
textf->QString+"3";
}
}
void CalcTrial::fourButtonClicked()
{
if(textf==NULL)
{
textf->setText("4");
}
else
{
textf->QString+"4";
}
}
void CalcTrial::fiveButtonClicked()
{
if(textf==NULL)
{
textf->setText("5");
}
else
{
textf->QString+"5";
}
}
void CalcTrial::sixButtonClicked()
{
if(textf==NULL)
{
textf->setText("6");
}
else
{
textf->QString+"6";
}
}
void CalcTrial::sevenButtonClicked()
{
if(textf==NULL)
{
textf->setText("7");
}
else
{
textf->QString+"7";
}
}
void CalcTrial::eightButtonClicked()
{
if(textf==NULL)
{
textf->setText("8");
}
else
{
textf->QString+"8";
}
}
void CalcTrial::nineButtonClicked()
{
if(textf==NULL)
{
textf->setText("9");
}
else
{
textf->QString+"9";
}
}
void CalcTrial::zeroButtonClicked()
{
if(textf==NULL)
{
textf->setText("0");
}
else
{
textf->QString+"0";
}
}
void CalcTrial::addButtonClicked()
{
operation=1;
temp1 = QString(getchar())+textf;
textf->setText(NULL);
}
void CalcTrial::minusButtonClicked()
{
operation=2;
temp1 = QString(getchar())+textf;
textf->setText(NULL);
}
void CalcTrial::mulButtonClicked()
{
operation=3;
temp1 = QString(getchar())+textf;
textf->setText(NULL);
}
void CalcTrial::divButtonClicked()
{
operation=4;
temp1 = QString(getchar())+textf;
textf->setText(NULL);
}
void CalcTrial::equalButtonClicked()
{
temp2 = QString(getchar())+temp1;
switch (operation) {
case 1:
result=temp1+temp2;
break;
case 2:
result=temp1-temp2;
break;
case 3:
result=temp1*temp2;
break;
case 4:
result=temp1/temp2;
break;
default:
break;
}
textf->text(result);
}
将QString转换为int:
QString strNum = "22";
int intNum = strNum.toInt();
相关文章:
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 代码在main()中运行,但在函数中出现错误
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 编译包含字符串的代码时遇到问题
- 我在c++代码中生成了一个运行时#3异常
- 如何在linux终端中同时编译和运行c++代码
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 在Linux for Windows上编译C++代码时出错
- 我的字符计数代码计算错误.为什么
- 孤立代码块在结构中引发异常
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 此代码是否违反一个定义规则
- 为什么我的代码在输出中增加了93天
- 我的简单if-else语句是如何无法访问的代码
- 使用动态分配的数组会导致代码分析发出虚假的C6386缓冲区溢出警告
- 为什么在这个代码结束循环中没有得到结束
- 在c代码之间共享数据的最佳方式
- 黑莓10中的CALC代码