Qt QLineEdit

时间:2021-01-04 20:03:34
//lineEdit显示文字
QLineEdit *lineEdit = new QLineEdit(widget);
lineEdit->setObjectName(QString("lineEdit%1").arg(i + ));
lineEdit->setText(QString("window %1").arg(i + ));
lineEdit->setStyleSheet(" font:bold; font-size:30px; font-style:italic; color:white;"
" border-radius:5px; border: 1px gray ;"
"background:transparent; selection-background-color: darkgray;");
lineEdit->setReadOnly(true);
// lineEdit->setGeometry(60,170,100,20); //设置位置

1、设置不可编辑四种方法:

setReadOnly(false);
setEnabled(false);
setFocusPolicy(Qt::NoFocus);//无法获得焦点,自然无法输入,其他文本控件类似
hasAcceptableInput(false);

参考:https://www.cnblogs.com/nanqiang/p/10026678.html
参考:https://blog.csdn.net/qq_40194498/article/details/79792419