[solved ]QLabels with different margins on different font sizes?



  • Hey all,

    I hope someone might be able to help me. For my project I need to set multiple QLabels with different font size in one horizontal layout. The problem is though, that the labels seem to have different margins. It seems to increase, whenever the font increases. This can even be reproduced in QtDesigner. The stylesheet I use looks like this:

    @QLabel { padding-left: 0px; margin-left: 1px; }@

    All other margins and spacings from layout are set to zero.
    I've found a bug report, which is maybe related to this: https://bugreports.qt-project.org/browse/QTBUG-11520

    Is there someone out there, who had a similar problem and found a solution?

    Thank you and take care.

    edit: set to solved



  • Hi,

    set QLabel text->indent to 0 in designer

    Cheers!



  • You totally saved my day! :)

    I'm just curious why it does not work to set this in stylesheets.



  • Just found the solution, setting
    @QLabel { qproperty-indent: 0; }@
    as stylesheet removes the indent from all QLabels.

    Thanks again.



  • it works!

    qproperty-indent:0;

    and in this way all properties which are declared by Q_PROPERTY in classes inheriting QObject ... just check the doc

    P.S.

    bq. as stylesheet removes the indent from all QLabels

    as default with negative value, I think it is actually skipped while the style sheet is applied ...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.