当前位置:网站首页>Interpretation of QT keypressevent

Interpretation of QT keypressevent

2022-06-13 04:53:00 qq_ thirty-nine million two hundred and eighty thousand seven h

Qt KeyPressEvent Function introduction :

KeyPressEvent Is a key press event handler ;
To get a key press event , This part must call setFoucusPolicy() function , Initialize focus , And getting the focus .
When you reload KeyPressEvent Function time , If you don't operate the keys , You need to call the overloaded function of the base class .
default KeyPressEvent function , The user presses the cancel key ( Typical is ESC Key ), Close the ejected part . Other keys will be ignored , Refer to parent components for processing .

Particular attention :
QKeyEvent The first thing that came in was IsAccepted() 了 , You don't have to call QKeyEvent::accept() Set the event status attribute ; If you want to operate the keys , You just don't call the overloaded functions of the base class ;

setFoucusPolicy Reading

Set how the part accepts the key value of the keyboard focus .
Particular attention : The default method is Qt::NoFocus, Do not deal with focus .
 Insert picture description here

KeyPressEvent Use

原网站

版权声明
本文为[qq_ thirty-nine million two hundred and eighty thousand seven h]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202280518242334.html