• 7474阅读
  • 4回复

信号editingFinished()的问题 [复制链接]

上一主题 下一主题
离线microx
 
只看楼主 倒序阅读 楼主  发表于: 2008-03-08
— 本帖被 XChinux 执行加亮操作(2008-03-10) —
我有个QLineEdit控件,且设置了validator 。QT的官方文档上说设置了validator的QLineEdit控件在失去焦点时是不会发送editingFinished()信号的如果它此时的输入文本不是QValidator::Acceptable的话。我试下来也的确是这样。
我现在想达到的效果是如果QLineEdit的文本不是QValidator::Acceptable的,那在它失去焦点是我想把它的内容清空,不知道这样怎么才能做到。请高手指点一下,谢谢!
离线zncggaofei
只看该作者 1楼 发表于: 2008-03-09
你先把信号接出来,再用validator验证,通过OK, 不通过清空LineEdit
There is someone that is coming or passing away in your life around the clock, so you may lose sight of those seen, and forget those remembered. There is gain and loss in your life, so you may catch sight of those unseen, and remember those forgotten. Nevertheless, doesn’t the unseen exist for sure? Will the remembered remain forever?
离线microx
只看该作者 2楼 发表于: 2008-03-14
怎么叫把信号接出来?  QLineEdit 根本不发信号啊
离线zncggaofei
只看该作者 3楼 发表于: 2008-03-14
void MainWindow::on_LineEdit_editingFinished()
{
        //validator验证lineEdit
        if (OK)
        //OK
        else
        //清空lineEdit
}
There is someone that is coming or passing away in your life around the clock, so you may lose sight of those seen, and forget those remembered. There is gain and loss in your life, so you may catch sight of those unseen, and remember those forgotten. Nevertheless, doesn’t the unseen exist for sure? Will the remembered remain forever?
离线microx
只看该作者 4楼 发表于: 2008-03-15
估计你还是没明白我的问题,你贴的这个函数是要QLineEdit发送了editingFinished()信号才会被触发执行的吧,但设置了QValidator的LineEdit根本不会发送editingFinished()信号啊,请问我怎么才能调用执行你那个函数?
快速回复
限100 字节
 
上一个 下一个