Results 1 to 2 of 2

Thread: QSS Styling for Widgets within Widgets

  1. #1
    Join Date
    Nov 2015
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default QSS Styling for Widgets within Widgets

    What I'm trying to achieve is to have all the widgets of a certain type that are within another widget to be styled differently from the rest of the application. I've done this before but I can't seem to figure it out. For example:

    MyCustomWidget has a layout and many widgets within that layout, including but not limited to QCheckBoxes. I want to style all the QCheckBoxes within MyCustomWidget to be styled in a certain way without affecting the rest of the QCheckBoxes in the application. I'd also like to be able to style them all at once and not have to name each single one and then make them have the same style.

    I've tried to do it with something like:
    MyCustomWidget::QCheckBox {
    ...
    }
    But that doesn't seem to work.

    I've been looking at the QSS Styling Reference and I couldn't seem to find a solution to this particular problem.

    Thanks in advanced
    Cheerio

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QSS Styling for Widgets within Widgets

    Qt Code:
    1. MyCustomWidget QCheckBox {
    2. }
    To copy to clipboard, switch view to plain text mode 
    or if only direct children of MyCustomWidget (no intermediary container allowed)
    Qt Code:
    1. MyCustomWidget > QCheckBox {
    2. }
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

Similar Threads

  1. Replies: 4
    Last Post: 2nd February 2014, 07:35
  2. Styling a QListView with custom widgets
    By ALz in forum Qt Programming
    Replies: 0
    Last Post: 27th September 2012, 13:41
  3. Replies: 0
    Last Post: 30th April 2012, 16:17
  4. Replies: 2
    Last Post: 30th March 2011, 21:20
  5. Replies: 5
    Last Post: 19th April 2010, 00:31

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.