QT QLineEdit设置密码格式的符号更改*号或者五角星
//-------------------------------------
//https://bbs.csdn.net/topics/392513644?page=1#post-414289855
// https://doc.qt.io/archives/qt-4.8/stylesheet-examples.html
//字符百科查询字符显示对应的HTML代码编号,五角星就是9733, https://unicode-table.com/cn/
//-------------------------------------
#include "mainwindow3_10.h"
#include "ui_mainwindow3_10.h"
#include
MainWindow3_10::MainWindow3_10(QWidget *parent)
: QWidget(parent)
, ui(new Ui::MainWindow3_10)
{
ui->setupUi(this);
//QString styleSheet=QString("QLineEdit[echoMode=\"2\"]{ lineedit-password-character: 42 }");//*号显示*
// QString styleSheet=QString("QLineEdit[echoMode=\"2\"]{ lineedit-password-character: 9835 }");//音乐符号显示♫
QString styleSheet=QString("QLineEdit[echoMode=\"2\"]{ lineedit-password-character: 9733 }");//实心五角星符号显示★
//-------------------------------------
//https://bbs.csdn.net/topics/392513644?page=1#post-414289855
// https://doc.qt.io/archives/qt-4.8/stylesheet-examples.html
//字符百科查询字符显示对应的HTML代码编号,五角星就是9733,https://unicode-table.com/cn/
//-------------------------------------
ui->lineEdit_1->setStyleSheet(styleSheet);
}
MainWindow3_10::~MainWindow3_10()
{
delete ui;
}
void MainWindow3_10::on_lineEdit_2_returnPressed()//按下回车后执行的操作
{
// ui->lineEdit_3->setFocus();
// qDebug()text();
// qDebug()displayText();
}
未设置成功设置失败的原因:
主界面右键-》改变样式表,设置了背景颜色获取其它的内容,将导致设置密码显示的符号失败,会变成默认的小黑点。