Home > Mobile >  About QLineEdit add ICONS on the right side (click to view the password, click on the hidden passwor
About QLineEdit add ICONS on the right side (click to view the password, click on the hidden passwor

Time:05-20

,, can you tell me the QLineEdit add ICONS on the right side, click view your password, click on the hidden password, why the following code shows the right side of the icon will spin down? What method can let it shows some normal or good?
Specific code is as follows:
The class pwdLineEdit: public QLineEdit
{
Q_OBJECT
Public:
Explicit pwdLineEdit (QWidget * parent=nullptr);
~ pwdLineEdit ();

Signals:

Public slots:

};


//pwdLineEdit
PwdLineEdit: : pwdLineEdit (QWidget * parent)
: QLineEdit (parent)
{
SetStyleSheet (" QLineEdit {background: transparent; Border - image: url (:/res/PWD/lineEditBkg PNG); Border - style: solid; Color: # 003 da6; Padding - left: + 8 px; Border - color: # 232423; The font: 11 px "" SimHei" "; }
""QLineEdit: hover {border: 1 px solid # 014099; }
""QLineEdit: focus {border: 1 px solid # 014099; }
""QLineEdit: hover {border: 1 px solid # 014099; }
""QLineEdit QPushButton {width: 16 px; height: 16px; Qproperty - flat: true, Margin - right: 4 px; border: none; Border - width: 0; Border - image: url (:/res/PWD/password_hide PNG) 0 0 0 0 stretch stretch; Background: transparent; }
""QLineEdit QPushButton: : checked {border - image: url (/res/PWD/password_show. PNG) 0 0 0 0 stretch stretch; } ");
SetEchoMode (QLineEdit: : ");
QPushButton * button=new QPushButton ();
The button - & gt; SetCursor (Qt: : PointingHandCursor);
The button - & gt; SetCheckable (true);
The connect (button, & amp; QPushButton: : toggled, [this] (bool checked) {
If (checked)
{
SetEchoMode (QLineEdit: : Normal);
}
The else
{
SetEchoMode (QLineEdit: : ");
}
});

QHBoxLayout * layout=new QHBoxLayout ();
Layout - & gt; AddStretch ();
Layout - & gt; AddWidget (button);
Layout - & gt; SetContentsMargins (0, 0, 0, 0);
SetLayout (layout);
}

PwdLineEdit: : ~ pwdLineEdit ()
{

}

Specific rendering is as follows:


CodePudding user response:

Don't use border - image that follow control size, or the proportion of the size of the button fixed into the picture,

CodePudding user response:

reference 1/f, it is a nice nickname response:
don't use border - image that follow control size, or the size of the button fixed into the picture, the proportion of

Bosses, just tried to put the button fixed become:/res/PWD/password_show. PNG or:/res/PWD/password_hide. PNG, as if there is not much change, as well as effect of screenshots,
The border - image background figure this temporarily cannot be replaced, because the project requirements limit the background picture,,,

CodePudding user response:

refer to the second floor lwei2 response:
Quote: reference 1/f, it is a nice nickname response:
don't use border - image that follow control size, or the size of the button fixed into the picture, the proportion of

Bosses, just tried to put the button fixed become:/res/PWD/password_show. PNG or:/res/PWD/password_hide. PNG, as if there is not much change, as well as effect of screenshots,
The border - image background figure this temporarily cannot be replaced, because the project requirements limit the background picture,,,


What I mean is that of the specified button fixdsize
Or use seticon and seticonsize
Don't let you fixed with a picture or change the picture
Border - image will place the bitmap as big as a control
  •  Tags:  
  • Qt
  • Related