QLineEdit
クリックだったかどうかを知りたいです。したがって、次の関数を再実装する必要があると思います(??):
void QLineEdit::focusInEvent ( QFocusEvent * e ) [virtual protected]
どうすればいいですか?
また、オブジェクトがフォーカスfocusInEvent()
されたかどうかを知る関数の使い方を教えてください。QLineEdit myEdit;
編集:私は次の関数を書きました:
bool LoginDialog::eventFilter(QObject *target, QEvent *event)
{
if (target == m_passwordLineEdit)
{
if (event->type() == QEvent::FocusIn)
{
if(checkCapsLock())
{
QMessageBox::about(this,"Caps Lock", "Your caps lock is ON!");
}
return true;
}
}
return QDialog::eventFilter(target, event);
}
そして、次のようにクラスコンストラクターに登録m_passwordLineEdit
しました:LoginDialog
m_passwordLineEdit->installEventFilter(this);
そして、MessageBox-es の無限ループに陥っています。この状況を解決するために私を助けてください。実際には、この機能をポップアップ ウィンドウ (ではなくQMessageBox
) で実装したいと考えています。その必要性のために使用しても大丈夫QLabel
ですか?