mainwindow.cpp 1 #include "mainwindow.h" 2 #include "ui_mainwindow.h" 3 #include <QDebug> 4 5 MainWindow::MainWindow(QWidget *parent) : 6 QMainWindow(parent), 7 ui(new Ui::MainWindow) 8 { 9 ui->setupUi(this); 10 } 11 12 MainWindow::~MainWindow() 13 { 14 delete ui; 15 } 16 17 void MainWindow::on_pushButton_clicked() 18 { 19 QString qstr1; 20 QString qstr2; 21 qstr1 = ui->lineEdit->text(); 22 qstr2 = ui->lineEdit_2->text(); 23 QString qstr3 ; 24 // qstr3 = qstr1 + qstr2 25 qstr3.sprintf("%s%d%s","123",45,"abc"); 26 qDebug() << qstr3 << endl; 27 ui->textEdit->setText(qstr3); 28 } 29 30 void MainWindow::on_pushButton_2_clicked() 31 { 32 QString qstr3=QString("%1 is %2").arg("hello").arg(123); 33 ui->textEdit->setText(qstr3); 34 }
转载于:https://www.cnblogs.com/xiaochi/p/8733521.html
