C++ (Qt)bool Client::eventFilter(QObject *target, QEvent *event) { if (target == lineEdit && event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); QString strkey = keyEvent->text(); if(lineEdit->text().isEmpty()) { lineEdit->setText(strkey.toUpper()); return true; } } return QObject::eventFilter(target, event);}
C++ (Qt)void DoctorForm::upp(const QString &str){ QLineEdit *le = qobject_cast<QLineEdit *>(sender()); if (!le) return; QString st; if(str.size()==1) le->setText(str.toUpper()); else { st=str.right(1).toLower(); le->setText(str.left(str.size()-1).append(st)); }}