Quantcast
Channel: Installation and Deployment
Viewing all articles
Browse latest Browse all 22112

Noob problem with QLCDnumber

$
0
0
I’m trying to create a calculator app to learn more about using Qt. I’ve created the UI no problem, however, I’m trying to make it display the numbers when the button is pressed, but it keeps crashing every time I press a button that I’ve added a socket for. I ran the debugger and it said that there was an exception. I can’t tell what the exception is though. Display is the QLCDNumber thingy. #include "calculator.h" #include <QLCDNumber> #include <QMessageBox> Calculator::Calculator(QWidget *parent) :     QWidget(parent), ui(new Ui::Calculator) {     ans = 0;     currVal = 0;     setupUi(this);   }   long long int Calculator::ans = 0; long long int Calculator::currVal = 0;     QString Calculator::getNewVal(long long int nextDig) {       long long int val = currVal;       if(nextDig==0)     {         if(val > 0)         {             QString str = QString::number(val);             str.append("0");             currVal = str.toLongLong((bool*)true);             return str;         }         else         {             return "0";         }     }     else if(nextDig==1)     {         QString str = QString::number(val);         str.append("1");         currVal = (long long int)str.toLongLong();         return str;     }     return ""; }     void Calculator::on_Zero_clicked() {     QMessageBox::information(this, "", "You have pressed Zero.");   //------------------------------------------------     ui->Display->display(getNewVal(0));//problem line //------------------------------------------------ }   void Calculator::on_One_clicked() {     QMessageBox::information(this,"", "You have pressed One.");     //------------------------------------------------     ui->Display->display(getNewVal(1));//problem line //------------------------------------------------ }

Viewing all articles
Browse latest Browse all 22112

Trending Articles