Qt 6.11 is out! See what's new in the release
blog
QLineEdit indicator
-
I would suggest to change the stylesheet to perhaps change the color when the user edits the text and clears it when submitted:
QWidget* myWidget = new QWidget(nullptr); QVBoxLayout *vboxLayout = new QVBoxLayout(myWidget); QLineEdit* edit = new QLineEdit("Test"); connect(edit, &QLineEdit::textChanged, [edit]{edit->setStyleSheet("background-color: yellow");}); QPushButton* submitButton = new QPushButton("Submit"); connect(submitButton, &QPushButton::clicked, [edit]{edit->setStyleSheet(""); }); vboxLayout->addWidget(edit); vboxLayout->addWidget(submitButton); myWidget->show();The above code is a very simple example to show the idea. But you can update as you need to.
-
A less manual solution is to add an action to the line edit using addAction(). Then you can just change the action's icon to indicate the state.
-
A less manual solution is to add an action to the line edit using addAction(). Then you can just change the action's icon to indicate the state.
@Chris-Kawa
Hi
I have tried this but the icon does not show upm_action = new QAction(this); QIcon icon(":/cross.png"); m_action->setIcon(icon); ui->nameEdit->addAction(m_action); -
Should be something like:
QIcon icon(":/cross.png"); m_action = ui->nameEdit->addAction(icon, QLineEdit::TrailingPosition);