Quantcast
Viewing all articles
Browse latest Browse all 4972

Forcing uppercase only into QLineEdit

How can i set a line edit (named textbox1) to uppercase only? I tried InputMethodHints: #include "mainwindow.h" #include "ui_mainwindow.h"   MainWindow::MainWindow(QWidget *parent) :     QMainWindow(parent),     ui(new Ui::MainWindow) {     ui->setupUi(this);     ui->textbox1->setMaxLength(50);     ui->textbox1->setInputMethodHints(Qt::ImhUppercaseOnly); } I tried it via the Design Mode as well, going to properties, expanding the InputMethodHints list and selecting ImhUppercaseonly checkbox. I also tried this: void MainWindow::on_textbox1_textChanged(const QString &arg1) {     QFont.setCapitalization(QFont::AllUppercase); } and this:     QValidator::State pqUpcaseValidator::validate(QString& Text, int& Pos) const     {         Text=Text.Upper();         return Acceptable;     } Any help would be appreciated. Thank you.

Viewing all articles
Browse latest Browse all 4972

Trending Articles