为什么我的QLineEdit和QPushButton之间不能用左右键控制呢???(请大侠们快点指教~怎么没人回呢?急的...)
为什么我的QLineEdit和QPushButton之间不能用左右键控制呢???(公司不要我用tab键,只要左右键)
我的代码...
QsmpFind.cpp:
void QsmpFind::keyPressEvent(QKeyEvent *event){
if(event->key()==Qt::Key_Down)
{ movePrevious();
}
if(event->key() == Qt::Key_Up)
{ moveNext();
}
//hope can use left & right key...
if(event->key()==Qt::Key_Left)
{ movePrevious();
}
if(event->key() == Qt::Key_Right)
{ moveNext();
}
}
void QsmpFind::setLocation(int i){
widgetLocation=i;
}
int QsmpFind::getLocation(){
return widgetLocation;
}
void QsmpFind::activeWidget(int i){
if(i%2!=0){
lineEditFind->setReadOnly(true);
}
else if(i%2==0){
lineEditFind->setReadOnly(false);
}
}
void QsmpFind::movePrevious(){
--widgetLocation;
setLocation(widgetLocation);
activeWidget(getLocation());
}
void QsmpFind::moveNext(){
++widgetLocation;
setLocation(widgetLocation);
activeWidget(getLocation());
}
上下键和左右键调用的是同样的方法,但是为什么左右键就是不起作用,我知道肯定是因为QEditLine的输入关系,但是最最关键的解决方法不知道...哪位大虾帮帮小妹啊!!!
(刚学qt,如果觉得编的很蠢,千万不要嘲笑啊...)