Home > database >  Can't assign a QString as a value for a LineEdit in Qt
Can't assign a QString as a value for a LineEdit in Qt

Time:04-03

I am working on a simple calculator app in Qt. I want to display an error message when the user tries to divide by zero. I have tried the code below but the output just stays as 0.

            if(dblDisplayVal == 0.0){
            QString error = "Can't divide by zero!";

            ui->display->insert(error);
        }
        else{
            result = calcVal / dblDisplayVal;
            divTrigger = false;

        }

Any idea on how I can solve this issue?

CodePudding user response:

you should use enter image description here

  • Related