Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved ]QLabels with different margins on different font sizes?

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

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    redschmidt
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • N Offline
      N Offline
      NicuPopescu
      wrote on last edited by
      #2

      Hi,

      set QLabel text->indent to 0 in designer

      Cheers!

      1 Reply Last reply
      0
      • R Offline
        R Offline
        redschmidt
        wrote on last edited by
        #3

        You totally saved my day! :)

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

        1 Reply Last reply
        0
        • R Offline
          R Offline
          redschmidt
          wrote on last edited by
          #4

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

          Thanks again.

          1 Reply Last reply
          0
          • N Offline
            N Offline
            NicuPopescu
            wrote on last edited by
            #5

            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 ...

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved