Getting text from QLineEdit to append to QTextEdit upon QLineEdit returnpressed()
Date : March 29 2020, 07:55 AM
I wish did fix the issue. When you run your program, you should notice on the console the following Qt error output.. Object::connect: No such slot QTextEdit::append(lineEdit.text()) in ..
|
Qt: Synchronous QLineEdit and QTextEdit
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , you can have a UpdateTextEdit slot in your window/dialog's class, like this: void ExampleDialog::UpdateTextEdit(){
QString str= ui->lineEdit1->text();
str+= "\n";
str+= ui->lineEdit2->text();
str+= "\n";
str+= ui->lineEdit3->text();
str+= "\n";
...
//add text from all your line edits
...
ui->textEdit->setPlainText(str);
}
ExampleDialog::ExampleDialog(QWidget* parent):QDialog(parent),...{
...
...
connect(ui->lineEdit1, SIGNAL(textChanged(const QString &)), this, SLOT(UpdateTextEdit()));
connect(ui->lineEdit2, SIGNAL(textChanged(const QString &)), this, SLOT(UpdateTextEdit()));
connect(ui->lineEdit3, SIGNAL(textChanged(const QString &)), this, SLOT(UpdateTextEdit()));
...
}
|
How to change the focus of QLineEdit automatically to another QLineEdit after input satisfy a criterion?
Tag : qt , By : Ben Brown
Date : November 04 2020, 11:01 PM
hop of those help? You need to check if edt1.hasAcceptableInput() every time textChanged() signal is emitted, and call edt2.setFocus() if it does. #include <QtWidgets>
int main(int argc, char** argv)
{
QApplication a{argc, argv};
QWidget w;
QLineEdit lineEdit1;
QLineEdit lineEdit2;
//validator to accept two digits
QRegExpValidator validator{QRegExp{"\\d{2}"}};
lineEdit1.setValidator(&validator);
lineEdit2.setValidator(&validator);
QVBoxLayout layout{&w};
layout.addWidget(&lineEdit1);
layout.addWidget(&lineEdit2);
w.show();
QObject::connect(&lineEdit1, &QLineEdit::textChanged, [&](){
if(lineEdit1.hasAcceptableInput())
lineEdit2.setFocus();
});
return a.exec();
}
|
Qt novice: base class for QLineEdit and QTextEdit
Date : March 29 2020, 07:55 AM
help you fix your problem There is no other way besides QWidget. The reason is that QLineEdit is inherited directly from QWidget. You can see the full hierarchy of Qt classes here
|
QLineEdit::textEdited() equivalent in QTextEdit?
Date : March 29 2020, 07:55 AM
|