Results 1 to 2 of 2

Thread: How to set outer border for QWidget so that it's inner widgets are unaffected?

  1. #1
    Join Date
    Apr 2011
    Posts
    8
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default How to set outer border for QWidget so that it's inner widgets are unaffected?

    Greetings!

    I have quite a strange problem. I have a QWidget with QHBoxLayout on it. The layout contains two QLabels.
    I want to set a border for this whole widget. I'm using style sheet:
    "padding: 10px;"
    "border-style: solid;"
    "border-width: 3px;"
    "border-radius: 7px;"
    "min-width: %1px;"
    "max-width: %2px;"

    But here's the problem: this style is applied to both QLabels and completely breaks the layout. I only need the outer window to have the border, not the labels.
    Any ideas?

    Thanks in advance!

  2. #2
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: How to set outer border for QWidget so that it's inner widgets are unaffected?

    Hi,

    the stylesheet is valid for the children by "default".

    You might want to read about selector types here:
    http://qt-project.org/doc/qt-4.8/stylesheet-syntax.html
    or else (if you don't find what you need there) here:
    http://www.w3.org/TR/CSS2/selector.html#q1

Similar Threads

  1. Border-image not working in QWidget?
    By astampor in forum Qt Programming
    Replies: 4
    Last Post: 3rd October 2011, 15:16
  2. Customised QWidget border
    By chandan in forum Newbie
    Replies: 1
    Last Post: 2nd March 2011, 17:08
  3. QWidget's border style
    By luochen601 in forum Qt Programming
    Replies: 2
    Last Post: 13th September 2010, 07:17
  4. Dock widget between widgets, not near the border
    By maverick_pol in forum Qt Programming
    Replies: 0
    Last Post: 22nd May 2009, 13:23
  5. Showing QWidget border around the window
    By maverick_pol in forum Qt Programming
    Replies: 2
    Last Post: 20th March 2008, 20:14

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.