Results 1 to 1 of 1

Thread: Styling a Sub-Control based on a Property of the Parent

  1. #1
    Join Date
    May 2007
    Posts
    90
    Thanks
    40
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Styling a Sub-Control based on a Property of the Parent

    I am trying to set the background of a QDockWidget Title bar based on a custom boolean Q_Property I added to a subclass I created.

    I know I can do this by calling "setStyleSheet" programmatically, but I was hoping to do it in the style sheet.

    Currently this is what I am doing in my style sheet:

    Qt Code:
    1. QDockWidget#MyDockWidget[myDockWidgetProperty="true"]::title
    2. {
    3. background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #AAAAAA, stop: 0.2 #666666, stop: 0.5 #444444, stop: 1.0 #222222);
    4. }
    To copy to clipboard, switch view to plain text mode 

    But that does not seem to do it. I have also tried

    Qt Code:
    1. QDockWidget#MyDockWidget::title[myDockWidgetProperty="true"]
    2. {
    3. background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #AAAAAA, stop: 0.2 #666666, stop: 0.5 #444444, stop: 1.0 #222222);
    4. }
    To copy to clipboard, switch view to plain text mode 

    But that also failed. In my code I am setting the object name of all my custom dock widgets as "MyDockWidget"


    Is there a way to make this work?

    Thanks in advance


    Added after 31 minutes:


    Tried the following also:

    Qt Code:
    1. QDockWidget#MyDockWidget[myDockWidgetProperty="true"] QDockWidget::title
    2. {
    3. background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #AAAAAA, stop: 0.2 #666666, stop: 0.5 #444444, stop: 1.0 #222222);
    4. }
    To copy to clipboard, switch view to plain text mode 

    Hoping that the "QDockWidget::title" would think to look only for a child title and not a child QDockWidget, but that does not seem to have worked either.
    Last edited by TheGrimace; 10th September 2013 at 16:03.

Similar Threads

  1. Replies: 7
    Last Post: 8th February 2013, 23:26
  2. styling parent but not child?
    By ugluk in forum Qt Programming
    Replies: 3
    Last Post: 13th October 2011, 02:55
  3. QAxServer-based ActiveX control crashes gdb
    By barbicels in forum Qt Programming
    Replies: 0
    Last Post: 15th September 2010, 16:12
  4. Replies: 2
    Last Post: 27th May 2010, 01:55
  5. Replies: 2
    Last Post: 2nd November 2009, 13:24

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.