Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Switch
Qt 6.11 is out! See what's new in the release blog

Switch

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 888 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    machakhama
    wrote on last edited by
    #1

    @ int result =0;
    bool ok;
    QString str = "";
    // QString opp = ui->opp->text();
    int number1 = ui->editor->text().toInt(&ok, 25);
    int number2 = ui->editor1->text().toInt(&ok, 25);
    switch (ui->opp->text().toInt(&ok,2)) {
    case '+':
    result = number1+ number2;
    ui->editor->setText(str.setNum(result));
    break;
    case '-':
    result = number1-number2;
    ui->editor->setText(str.setNum(result));
    break;
    case 'x':
    result = number1*number2;
    ui->editor->setText(str.setNum(result));
    break;
    case '/':
    result - number1 / number2;
    ui->editor->setText(str.setNum(result));
    break;
    default:
    ui->editor->setText("Marth Error");
    break;
    }@
    I want to do operation by usibg switch by my code give me errof

    1 Reply Last reply
    0
    • C Offline
      C Offline
      clochydd
      wrote on last edited by
      #2

      Hi, AFAIK switch only works with integer.
      What is your error message?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved