Home > Mobile >  How can realize the control of style in Qt QSS updated?
How can realize the control of style in Qt QSS updated?

Time:10-13

Masters, you ask a question, how can realize control style update in QSS?

For example, an application scenario has the following:
A QLineEdit input box:
When focus after losing, would be to check whether meet the requirements, if do not conform to, change this input box color style such as:

QSS is as follows:
 
/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- QLineEdit -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - */
QLineEdit {border: # 1 px solid DDD; width:100%; font-size:14px; height:24px; line-height:24px; Padding: 4 px; }
QLineEdit {border: 1 px solid # BBB; }
QLineEdit {border: 1.3 px solid # 3 bb4f2; }
QLineEdit: disabled, QLineEdit: disabled: focus {background - color: # ededed; Border - color: # DDD; }
//////////this is where the key
QLineEdit: if it is wrong to {background - color: # fbe2e2; Border - color: # c66161; Color: # c00; }


Question: how should the writing mistakes in QSS that logo? How to reflect the style in the program? At the same time, after the input correctly, how to return to normal QLineEdit style?


Online, etc., thank you

CodePudding user response:

QLineEdit how to judge whether your input, this need your own judgment, not meet you reset the lineEdit QSS

CodePudding user response:

reference 1st floor sddsighhz response:
thank you for your reply,
QLineEdit how to judge whether your input, this need your own judgment, is not in conformity with all you have to do is to set up lineEdit QSS

How to determine the I is relatively easy to implement, but how to reset? I hope that after a reset style is to write in the QSS

CodePudding user response:

Custom QSS attribute to flip QSS help document, see how to customize QSS attributes to control

CodePudding user response:


Assistance there,

CodePudding user response:

reference 4 floor llq108 response:

Assistance with speaking,

Hello:
I saw you for the manual document, but I still didn't finish:
Now I for style set an attribute:
QLineEdit [stated="true"] {background - color: # fbe2e2; Border - color: # c66161; Color: # c00}

If the program start loading, I set the setProperty (" stated ", true); , then the control will display this kind of style,
But if initially QLineEdit stated attribute is false, and then I by clicking on the button after setting stated=true; Is the control no reaction,
Is excuse me this why? I should be a less, operation, trouble you,



CodePudding user response:

reference Esonpo reply: 3/f
custom QSS attribute, to flip QSS help document, see how to customize QSS properties to control

Hello,
Now I for style set an attribute:
QLineEdit [stated="true"] {background - color: # fbe2e2; Border - color: # c66161; Color: # c00}

If the program start loading, I set the setProperty (" stated ", true); , then the control will display this kind of style,
But if initially QLineEdit stated attribute is false, and then I by clicking on the button after setting stated=true; Is the control no reaction,
Is excuse me this why? I should be a less, operation, trouble you,

CodePudding user response:

Can be set against the ObjectName QSS:
LineEdit. SetObjectName (' normal ')
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
QSS file:
QLineEdit# normal {background:... ; }
QLineEdit# error {background:... ; }
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Judgment for the mistake, set the
LineEdit. SetObjectName (' error ')

But I didn't try, you can not try this...

CodePudding user response:

LineEdit. The update ()??
refer to 6th floor BSBSXLL response:
Quote: refer to the third floor Esonpo response:

Custom QSS attribute to flip QSS help document, see how to customize QSS properties to control

Hello,
Now I for style set an attribute:
QLineEdit [stated="true"] {background - color: # fbe2e2; Border - color: # c66161; Color: # c00}

If the program start loading, I set the setProperty (" stated ", true); , then the control will display this kind of style,
But if initially QLineEdit stated attribute is false, and then I by clicking on the button after setting stated=true; Is the control no reaction,
Is excuse me this why? I should be a less, operation, trouble you,


refer to 6th floor BSBSXLL response:
Quote: refer to the third floor Esonpo response:

Custom QSS attribute to flip QSS help document, see how to customize QSS properties to control

Hello,
Now I for style set an attribute:
QLineEdit [stated="true"] {background - color: # fbe2e2; Border - color: # c66161; Color: # c00}

If the program start loading, I set the setProperty (" stated ", true); , then the control will display this kind of style,
But if initially QLineEdit stated attribute is false, and then I by clicking on the button after setting stated=true; Is the control no reaction,
Is excuse me this why? I should be a less, operation, trouble you,


refer to 6th floor BSBSXLL response:
Quote: refer to the third floor Esonpo response:

Custom QSS attribute to flip QSS help document, see how to customize QSS properties to control

Hello,
Now I for style set an attribute:
QLineEdit [stated="true"] {background - color: # fbe2e2; Border - color: # c66161; Color: # c00}

If the program start loading, I set the setProperty (" stated ", true); , then the control will display this kind of style,
But if initially QLineEdit stated attribute is false, and then I by clicking on the button after setting stated=true; Is the control no reaction,
Is excuse me this why? I should be a less, operation, trouble you,


refer to 6th floor BSBSXLL response:
Quote: refer to the third floor Esonpo response:

Custom QSS attribute to flip QSS help document, see how to customize QSS properties to control

Hello,
Now I for style set an attribute:
QLineEdit [stated="true"] {background - color: # fbe2e2; Border - color: # c66161; Color: # c00}

If the program start loading, I set the setProperty (" stated ", true); , then the control will display this kind of style,
But if initially QLineEdit stated attribute is false, and then I by clicking on the button after setting stated=true; Is the control no reaction,
Is excuse me this why? nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • Qt
  • Related