Qt5 QLineEdit 点击调用软键盘

过滤 MousePressEvent 事件来完成 点击 QLineEdit 调用软键盘

bool eventFilter(QObject *watched, QEvent *event);

void callKeyBoard();
 ui->lineEdit_kv->installEventFilter(this) ;
//  事件过滤器函数重写 
bool init::eventFilter(QObject *watched, QEvent *event)
{
    if ( (watched == ui->lineEdit_kv) && (event->type() == QEvent::MouseButtonPress) )
    {
        callKeyBoard();
    }
    return QWidget::eventFilter(watched,event);
}

// 调用软键盘 
void init::callKeyBoard()
{
    ui->widget_bort->show() ;
}

你可能感兴趣的:(QT)