Qt之:按下Enter,獲取QLineEdit的編輯內容

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    QLineEdit *edit = new QLineEdit(this);

    connect(edit, SIGNAL(returnPressed()), this, SLOT(slotEditClicked()));
}

void Widget::slotEditClicked()
{
    QLineEdit* button = (QLineEdit*)sender();
    qDebug() << button->text();
}

相關文章
相關標籤/搜索