Results 1 to 5 of 5

Thread: Remove Borders around a QLabel

  1. #1
    Join Date
    May 2012
    Location
    India
    Posts
    51
    Thanks
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Default Remove Borders around a QLabel

    I have added one qlabel in my application's statusbar . And now I have been trying to remove the borders around the QLabel.

    Qt Code:
    1. label->setFrameShape(QFrame::HLine);
    2. label->setFrameStyle(QFrame::NoFrame);
    3. // label->setLineWidth(0);
    4. //label->setMidLineWidth(0);
    To copy to clipboard, switch view to plain text mode 
    I tried everything above, none of them work, any help is appreciated.

  2. #2
    Join Date
    Sep 2011
    Location
    Portugal
    Posts
    25
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Remove Borders around a QLabel

    You can define a stylesheet for the label:
    Qt Code:
    1. label->setStyleSheet("border: 0px;");
    To copy to clipboard, switch view to plain text mode 

    or for the parent QWidget:
    Qt Code:
    1. this->setStyleSheet("QLabel { border: 0px; }");
    To copy to clipboard, switch view to plain text mode 

    More about that, here: http://qt-project.org/doc/qt-4.8/sty...-examples.html

  3. #3
    Join Date
    May 2012
    Location
    India
    Posts
    51
    Thanks
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Remove Borders around a QLabel

    I have tried the above one , but it does not have any impact ..
    Could you please give any other method ?

  4. #4
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Thanks
    29
    Thanked 50 Times in 47 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Remove Borders around a QLabel

    it may work.

    Qt Code:
    1. label->setContentsMargins(0, 0, 0, 0);
    To copy to clipboard, switch view to plain text mode 
    Last edited by sonulohani; 13th July 2012 at 12:40.
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

  5. #5
    Join Date
    May 2012
    Location
    India
    Posts
    51
    Thanks
    4
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Remove Borders around a QLabel

    i got the solution

    we can do this with Style sheets. we probably have a line like this Application app(argc, argv);

    underneath that, add one like this: app.setStyleSheet("QStatusBar::item { border: 0px solid black }; ");

    and those pesky boxes will be gone.

Similar Threads

  1. buttons on frame borders
    By iori in forum Qt Programming
    Replies: 1
    Last Post: 19th May 2011, 09:30
  2. widget borders v4.2
    By dacrawler in forum Newbie
    Replies: 0
    Last Post: 24th January 2011, 20:08
  3. QGroupBox borders
    By onurozcelik in forum Qt Programming
    Replies: 0
    Last Post: 27th August 2010, 07:24
  4. Replies: 1
    Last Post: 29th September 2009, 20:44
  5. Groupbox has no borders ?
    By vieraci in forum Qt Programming
    Replies: 12
    Last Post: 30th April 2009, 13:46

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.