和5楼做法所见略同啊,呵呵。
代码:
frame = new QFrame(this);
frame->setGeometry(QRect(120, 100, 161, 31));
frame->setStyleSheet(QString::fromUtf8("QFrame {\n"
" background-color: white;\n"
"}"));
frame->setFrameShape(QFrame::Panel);
frame->setFrameShadow(QFrame::Sunken);
horizontalLayout = new QHBoxLayout(frame);
label = new QLabel(frame);
horizontalLayout->addWidget(label);
lineEdit = new QLineEdit(frame);
lineEdit->setStyleSheet(QString::fromUtf8("QLineEdit {\n"
" border:none;\n"
"}\n"
"QLineEdit[echoMode=\"2\"] {\n"
" lineedit-password-character: 42;\n"
"}"));
lineEdit->setEchoMode(QLineEdit::Password);
horizontalLayout->addWidget(lineEdit);
大功告成!