Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Spanish
  4. If anidados no funciona
Forum Updated to NodeBB v4.3 + New Features

If anidados no funciona

Scheduled Pinned Locked Moved Solved Spanish
3 Posts 1 Posters 713 Views
  • 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.
  • P Offline
    P Offline
    pedro1
    wrote on last edited by
    #1

    Buenas tardes.

    No se el motivo por el cual no funciona, el primer IF funciona correctamente, pero el segundo IF no funciona if(longitud > 20 or Texto.toInt() == 0), me toma los valores del primer IF if(longitud > 9 or Texto.toInt() == 0). Para que funcione este segundo IF, le tengo que quitar el "or" y dejarlo como if(longitud > 20) y anidar un nuevo if.

    Si me podeis ayudar. Gracias.

    void Tareas::on_salida2_cellChanged(int row, int column)
    {
    const QSignalBlocker blocker(ui->salida2);

    int longitud = ui->salida2->item(row,column)->text().length();
    QString Texto = ui->salida2->item(row,column)->text().toUtf8().simplified();

    if(column == 1)
    {
    if(longitud > 9 or Texto.toInt() == 0) // Este SI FUNCIONA
    {
    QMessageBox::critical (this, "ERROR", "Logitud Maxima 9 caracteres numéricos");
    ui->salida2->item(row,column)->setText("");
    }
    }

    else if(column == 2)
    {
    if(longitud > 20 or Texto.toInt() == 0) // Este NO FUNCIONA
    {
    QMessageBox::critical (this, "ERROR", "Logitud Maxima 20 caracteres numéricos ");
    ui->salida2->item(row,column)->setText("");
    }
    }
    }

    1 Reply Last reply
    0
    • P Offline
      P Offline
      pedro1
      wrote on last edited by
      #2

      Comentar que de esta otra forma Tampoco funciona, si alguien ve donde puedo estar cometiendo el error, se lo agradecería.

      void Tareas::on_salida2_cellChanged(int row, int column)
      {
      const QSignalBlocker blocker(ui->salida2);

      int longitud = ui->salida2->item(row,column)->text().length();
      QString Texto = ui->salida2->item(row,column)->text().toUtf8().simplified();

      if(column == 1 and (longitud > 9 or Texto.toInt() == 0)) // Este SI FUNCIONA
      {
      QMessageBox::critical (this, "ERROR", "Logitud Maxima 9 caracteres numéricos");
      ui->salida2->item(row,column)->setText("");
      }

      else if(column == 2 and (longitud > 20 or Texto.toInt() == 0)) // Este NO FUNCIONA
      {
      QMessageBox::critical (this, "ERROR", "Logitud Maxima 20 caracteres numéricos ");
      ui->salida2->item(row,column)->setText("");
      }
      }

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pedro1
        wrote on last edited by
        #3

        Gracias a todos.

        Ya he descubierto donde tengo el error.

        El error es que un número de 20 cifras NO ES INT.

        Lo he cambiado por:

        else if(column == 2 and (longitud > 20 or Texto.toDouble() == 0))

        y funciona.

        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