Qt常用UI控件读取、写入方法

【1、标签label】

读取:ui->label->text()
写入:ui->label->setText("poi");

【2、单行文本框lineEdit】
读取:ui->lineEdit->text()

写入:ui->lineEdit->setText("poi");

【3、单行文本框textEdit】
读取(文本):ui->textEdit->toPlainText()
读取(富文本):ui->textedit->toHtml()
写入:ui->textEdit->setText("poi");

追加:ui->textEdit->append("jfz");

【4、spinBox】

读取:ui->spinBox->text()

【5、doubleSpinBox】

读取:ui->doubleSpinBox->text()

【6、comboBox】

读取:ui->comboBox->currentText()

【7、radioButton】

读取:ui->radioButton->isChecked()

【8、checkBox】

读取:checkBox->checkState() == Qt::Checked

猜你喜欢

转载自blog.csdn.net/weixin_41157654/article/details/80820478
今日推荐