void MainWindow::keyPressEvent(QKeyEvent *event)
{
switch (event->key()) {
case Qt::Key_F1:
do something;
break;
default:
QWidget::keyPressEvent(event);
}
}
我查了些资料,视乎响应键盘按键需要“信号和槽”来配合?另外,我还想在点击窗口最大化按钮时干点事,请问这个怎么做?请高手指点!!多谢了!
4 个解决方案
#1
A widget must call setFocusPolicy() to accept focus initially and have focus in order to receive a key press event.
#2
我也是这有处理的,好像可以啊!可以参见:http://bbs.csdn.net/topics/390961598
#3
如果我要按窗口最大化按钮,然后处理一些事件,这个消息响应应该怎么处理呢?
#4
void QWidget::changeEvent ( QEvent * event ), QWindowStateChangeEvent
#1
A widget must call setFocusPolicy() to accept focus initially and have focus in order to receive a key press event.
#2
我也是这有处理的,好像可以啊!可以参见:http://bbs.csdn.net/topics/390961598
#3
如果我要按窗口最大化按钮,然后处理一些事件,这个消息响应应该怎么处理呢?
#4
void QWidget::changeEvent ( QEvent * event ), QWindowStateChangeEvent