1.QAction
void addAction(QAction * action, ActionPosition position)
QLineEdit::LeadingPosition//前面
QLineEdit::TrailingPosition//后面
2.自定义
QMargins margins=ui->lineEdit_3->textMargins();
tipLbl=new QLabel("密码正确",this);
ui->lineEdit_3->setTextMargins(margins.left(),margins.top(),tipLbl->width(),margins.bottom());//避免与文字重叠,需调整。
QHBoxLayout *layOut=new QHBoxLayout;
layOut->addStretch();
layOut->addWidget(tipLbl);
layOut->setSpacing(0);
layOut->setContentsMargins(0,0,0,0);
ui->lineEdit_3->setLayout(layOut);
评论区