c++ - QLabel margin and style sheet padding in labels in Qt -
i have label, , set both padding in style sheet , margin using setmargin().
ui->label->setpixmap(redrectwithgreenborder(80, 40)); ui->label->setstylesheet("qlabel {border: 1px solid gray;border-radius: 2px;background-color: white;padding: 0px 5px 10px 15px;}"); ui->label->setmargin(5); but how looks in reality:
the visible margins 5, 10, 15 , 20 (i checked image editor). is, equal value of style sheet side plus value of margin(), i.e. 0+5, 5+5, 10+5, 20+5.
however, documentation says setmargin():
margin : int property holds width of margin.
the margin distance between innermost pixel of frame , outermost pixel of contents.
the default margin 0.
if taking documentation @ face value, have expected margin real distance between content , border. not. instead, the sum of margin , style sheet padding real margin.
my question is, in documentation behavior described? there other place in documentation behavior specified have missed?
stylesheet padding applies all controls, not based on qlabel. exists in add-on control-specific mechanisms. margin qlabel-specific property predates stylesheets; available in qt 4.0 (at least). stylesheets came later, in qt 4.2.
another way think it: behavior can inferred fact there's 1 margin property, not four. property has nil stylesheet padding, since latter give 4 separate values of padding. there's no way reconcile other adding them up.
also, note margin , padding different terms. stylesheet specifies padding. qlabel specifies margin. may synonyms, that's irrelevant here. still different concepts within setting of qlabel. visual outcome due both. 4.0 margin's behavior had preserved in qt 4.2, not break existing code.
c++ qt qss
No comments:
Post a Comment