Forcing uppercase only into QLineEdit
-
This is what I've been doing.
Using your example
@ void MainWindow::on_textbox1_textChanged(const QString &arg1)
{
// QFont.setCapitalization(QFont::AllUppercase);
ui->textbox1.setText(arg1.toUpper());
}
@I was hoping there was a better way to do it. But it seems to me like there isn't.
-
This is what I've been doing.
Using your example
@ void MainWindow::on_textbox1_textChanged(const QString &arg1)
{
// QFont.setCapitalization(QFont::AllUppercase);
ui->textbox1.setText(arg1.toUpper());
}
@I was hoping there was a better way to do it. But it seems to me like there isn't.
-
Hi and welcome to devnet,
Why not use QRegExpValidator ?
-
Hi and welcome to devnet,
Why not use QRegExpValidator ?
-
Thank you for the warm welcome.
I do use QRegExpValidator quite frequently, but I feel like this restriction reduces usability. From my experience, a validator will force exact input only, and reject anything else. Unless I'm not using it correctly.
What I usually need is a qtextbox or qlineedit that accepts all input, then transforms the input to be valid and acceptable (eg. uppercase) and reflects the changes immediately while the user is typing. Hence the @SLOT (textChanged(QString))@.
Is there a better way of doing this?
-
Thank you for the warm welcome.
I do use QRegExpValidator quite frequently, but I feel like this restriction reduces usability. From my experience, a validator will force exact input only, and reject anything else. Unless I'm not using it correctly.
What I usually need is a qtextbox or qlineedit that accepts all input, then transforms the input to be valid and acceptable (eg. uppercase) and reflects the changes immediately while the user is typing. Hence the @SLOT (textChanged(QString))@.
Is there a better way of doing this?
-
Try using this:
@ui->textbox1->setText(QString::number(whatever you need to output,16).toUpper());@
-
Try using this:
@ui->textbox1->setText(QString::number(whatever you need to output,16).toUpper());@
-
You can also start capturing and modifying your key events.
-
You can also start capturing and modifying your key events.