connect(ui->b1,SIGNAL(clicked(bool)),this,SLOT(on_b1_clicked())); void MainWindow::on_b1_clicked() { char b1 = '1'; QString phone = ui->PhoneLineEdit->text().append(b1); qDebug() << phone; ui->PhoneLineEdit->setText(""); ui->PhoneLineEdit->setText(phone); } 

when you click on the button 1 in the window qlineedit output 1 and he writes 11. Where does he get it from?

  • Is that all the code? - KoVadim
  • no, but just line edit (PhoneLineEdit) through the designer created and qpushbutton (b1) as well. Next connect ... - Alexey Smirnov

1 answer 1

Try to put ui->PhoneLineEdit->clear at the beginning Maybe at you somewhere in GUI there was a unit

  • I removed the signals to the buttons and it all worked as it should. Probably the designer had already done everything himself, and I added it again manually. Well, in the end, he chased the slot twice - Alexey Smirnov