Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何更改通过光标键在 QGridLayout 中选择项目的行为?我想通过左/右光标键水平移动选择,并通过向上/向下键垂直移动选择。谁对此负责?布局、项目容器或标签顺序?
您可以重新实现keyPressEvent()主小部件的方法以捕获按下的键。然后,您可以通过调用QGridLayout::itemAtPosition (int row, int column)并设置焦点来访问布局中所需的小部件。
keyPressEvent()
QGridLayout::itemAtPosition (int row, int column)