• 4046阅读
  • 3回复

为什么我的QLineEdit和QPushButton之间不能用左右键控制呢???(请大虾指教!急的~) [复制链接]

上一主题 下一主题
离线woshimibao
 
只看楼主 倒序阅读 楼主  发表于: 2010-03-12
为什么我的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,如果觉得编的很蠢,千万不要嘲笑啊...)
[ 此帖被woshimibao在2010-03-12 17:39重新编辑 ]
离线benbenmajia

只看该作者 1楼 发表于: 2010-03-12
能不能用信号连接
安然.....
离线benbenmajia

只看该作者 2楼 发表于: 2010-03-12
能不能用信号连接
安然.....
离线woshimibao
只看该作者 3楼 发表于: 2010-03-12
不知你指的信号连接是用在哪里?如果说是用于如:connect(lineEditFind,SIGNAL(textChanged()),pushButtonFind,SLOT(setFocus()); 这样的意思的话,是不可以(公司不要这个)

我觉得我的问题是出在QLineEdit上,左右键被默认设为用于修改这个lineEdit的text了,而且不可以更改(有方法override那个left key or right key吗?...不清楚...)
快速回复
限100 字节
 
上一个 下一个