Results 1 to 9 of 9

Thread: style sheets

  1. #1
    Join Date
    May 2008
    Posts
    61
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default style sheets

    hi,

    I'm trying to modify the style sheet of some widgets. the problem is that, when I modify a property of the widget, all the other properties are gone.

    for example when I modify the border of a groupbox with the following "QGroupBox {border: 1px}" the border-radius is resetted etc. When I modify the border of a QComboBox, all the color information is gone.

    I am using the plastique style and I want to modify only some certain properties and leave the rest as it is ? Is there a way to do so ?

    Sami

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: style sheets

    it seems like you override old style sheet by new one. you have to whole style sheet or set style sheet for each widget separately.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: style sheets

    alisami meraba,

    Spirit is right, whenever you attempt to write for example;

    QComboBox* myComboBox;

    myComboBox->setStyleSheet( "background: red"); // background is red now

    myComboBox->setStyleSheet(" border-width: 2px; border-styleutset"); // background is not red now but borders are set

    namely, setStyleSheet is overidden by the lastly executed one. So you are supposed to wrtie the whole in one.

  4. #4
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: style sheets

    here in QProgressBar i want to change the style sheet of two items in progressBar()
    1, progressBar
    2, progressBar::chunk

    so to use this two properties separately .. the last stylesheet override my previous one ..
    so i use both in a single stylesheet settings ,
    setStyleSheet(" QProgressBar {border: 1px solid grey; border-radius:5px;} QProgressBar::chunk {background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 #C71585, stop: 1 white);}");

    just a space ' ' between the two stylesheet properties ... now both were working fine ..

  5. #5
    Join Date
    May 2008
    Posts
    61
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: style sheets

    hello again,

    what I wanted to ask was, is it possible to set only the border of a widget like
    QComboBox:border {blablabla}.

    but I guess there is no such way to do so.

    thanks for the replies,
    sami

  6. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: style sheets

    Of course there is a way, but your example
    Qt Code:
    1. border: 1px;
    To copy to clipboard, switch view to plain text mode 
    is the wrong CSS syntax for only changing the border width. Use
    Qt Code:
    1. border-width: 1px;
    To copy to clipboard, switch view to plain text mode 
    instead. Not proved with Qt but should work.

  7. #7
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: style sheets

    Hi,

    what's wrong with doing "QComboBox { border-width:1px; border-style: outset; border-color: red}" ?

    Are you trying to do it from the source or designer by the way?

  8. #8
    Join Date
    May 2008
    Posts
    61
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: style sheets

    actually I experienced this problem when I changed the QGroupBox main style.
    when that style is changed, the QGroupBox::title's padding is gone, so I had to modify it.

    the above can be observed by just putting the following style sheet in the designer to a widget:
    QGroupBox
    {
    border-width: 1px;
    border-color: #FF0000;
    border-radius: 1px;
    }

    actually I started thinking that I am missing a point about the style sheets.
    Last edited by alisami; 7th May 2009 at 10:42.

  9. #9
    Join Date
    May 2008
    Posts
    61
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: style sheets

    Quote Originally Posted by zgulser View Post
    Hi,

    what's wrong with doing "QComboBox { border-width:1px; border-style: outset; border-color: red}" ?

    Are you trying to do it from the source or designer by the way?
    the problem is that, I only want to change the border width. if I only specify the `border-width` nothing happens. I should also enter the `border-style` and `border-color` as well to see the border of the combo box.

    again, what I want to do is to only modify the border-width of any widget without entering the other parameters.

    I again tried in the designer but didn't manage to success.

Similar Threads

  1. Replies: 6
    Last Post: 14th April 2009, 18:40
  2. Performace problem with style sheets
    By Cruz in forum Qt Programming
    Replies: 0
    Last Post: 7th February 2009, 14:20
  3. style sheets select all except something
    By codeslicer in forum Qt Programming
    Replies: 4
    Last Post: 6th March 2008, 01:21
  4. BIG Problem with Background-image using Style Sheets
    By PiXeL16 in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2007, 23:10
  5. Qt style sheets
    By locus in forum Qt Programming
    Replies: 5
    Last Post: 5th April 2007, 18:03

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.