我正在部署Android下的Qt應用程序。當QLineEdit
長度有限(使用setMaxLength
)時,Android虛擬鍵盤允許輸入超出允許的字符數,並且隨後虛擬鍵盤關閉時QlineEdit
內容將被截斷。QLineEdit :: maxLength支持Android
#include <QApplication>
#include <QMainWindow>
#include <QVBoxLayout>
#include <QLineEdit>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QMainWindow wnd;
QLineEdit edit(&wnd);
edit.setMaxLength(10);
wnd.setCentralWidget(&edit);
wnd.show();
return app.exec();
}
有沒有辦法讓虛擬鍵盤處理這個限制不讓用戶輸入比允許的更多的字符?
注:創建QT錯誤:https://bugreports.qt.io/browse/QTBUG-61940
我有類似QLineEdit的問題。所有進入lineEdit的文本都會自動變爲大寫。 – aghilpro
你可以在事件QLineEdit文字改變的情況下獲得文本,並阻止用戶輸入更多的特定數量的字符,但這不是一個好的解決方案。 – aghilpro
@aghilpro:不好的解決方案,但可以接受... – jpo38