QLineEdit后面放置一个按钮

    QToolButton* btn = new QToolButton;
    btn->setText("...");
    btn->setCursor(Qt::ArrowCursor);
    QWidgetAction* action = new QWidgetAction(ui.lineEdit);
    action->setDefaultWidget(btn);
    ui.lineEdit->addAction(action, QLineEdit::TrailingPosition);

	connect(btn, &QToolButton::clicked, this, [this]() {
	 // do some thing
	});

 

©️2020 CSDN 皮肤主题: 技术黑板 设计师:CSDN官方博客 返回首页