Unsolved Show value entered in QTextEdit by user in a QLabel when user click submit button
-
How can I show the value entered in
QTextEdit
by user in aQLabel
when user click a submit button? -
QObject::connect(submitButton,&QPushButton::clicked,[=]()->void{label->setText(textEdit->toPlainText());});
-
Hi it's very simple ,
If you are using Qt widgets you you can do something like this:
connect(ui->submitButton,SIGNAL(clicked()),this,SLOT(onTextValidated()));
private slot: void onTextValidated();
in .cpp
onTextValidated() { ui->label->setText(ui->textEdit->toPlainText()); }
Hope this can help!
Edit: Added code tags -- @Wieland
-
@VRonin
where do i need t put this code in Mainwindow::Mainwindow() function or in the slot when my button is clicked ? -
@sanjay1155 said in Show value entered in textedit by user in a label when user click submit button:
in Mainwindow::Mainwindow() function
yes, in the constructor
slot when my button is clicked
if you already have a slot connected to
QPushButton::clicked
just addlabel->setText(textEdit->toPlainText());
to it instead of using my code