Results 1 to 4 of 4

Thread: QLabel top and bottom padding is not getting set to zero.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2017
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default QLabel top and bottom padding is not getting set to zero.

    Hello,

    I am trying to make the top and bottom padding zero in my QLabel. I have tried all the options below but none of them seem to work.
    Am i missing something? In smaller fonts, the padding is negligible. As the font size increases(in my case 192 Sans Serif), the top and bottom padding are too big to ignore.

    QLabel *newLabel = new QLabel("Text", this);
    this->setStyleSheet("QLabel { border: 0px; }");
    newLabel->setAlignment(Qt::AlignTop);
    newLabel->setStyleSheet("background-color: yellow; color: blue; font-size: 192px; padding: 0 0 0 0px; border: 0 0 0 0px");
    newLabel->setIndent(0);
    newLabel->setMargin(0);
    newLabel->setContentsMargins(0, 0, 0, 0);
    newLabel->setFrameShape(QFrame::HLine);
    newLabel->setFrameStyle(QFrame::NoFrame);


    Is there anything I must try?
    Any help would be greatly appreciated as this is really bothering me.

    Thank you.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QLabel top and bottom padding is not getting set to zero.

    Maybe it isn't the label at all, but the layout or other place where you are embedding it?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Qwt: curve with padding
    By alperyazir in forum Qwt
    Replies: 1
    Last Post: 11th November 2014, 11:19
  2. Adding some padding to a button
    By scarleton in forum Qt Programming
    Replies: 1
    Last Post: 12th June 2010, 16:18
  3. Replies: 1
    Last Post: 29th September 2009, 20:44
  4. QLineEdit padding
    By bunjee in forum Qt Programming
    Replies: 0
    Last Post: 17th September 2008, 23:43
  5. Replies: 7
    Last Post: 15th November 2007, 18:19

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.