Results 1 to 3 of 3

Thread: How do you set style sheets for various widgets?

  1. #1
    Join Date
    Aug 2011
    Posts
    33
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    11

    Default How do you set style sheets for various widgets?

    I have had very limited success with widget->setStyleSheet.

    I'm certain that it's "user error", but part of the problem is I just don't know where to go to get a list of valid properties for any given widget.

    For example, what are all the valid properties for QPushButton?

    How do I set a QPlainTextEdit box to have a sunken look?

    I have tried things like this ...
    Qt Code:
    1. bbStyle = "color: aqua; background-color: black; "
    2. "border-style: outaet; border-color: green;"
    3. "border-width: 2px";
    4.  
    5. this->setStyleSheet(QString(bbStyle));
    To copy to clipboard, switch view to plain text mode 

    ... but the only thing that works in that example is the background and foreground colors.

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

    Default Re: How do you set style sheets for various widgets?

    Quote Originally Posted by paie View Post
    I just don't know where to go to get a list of valid properties for any given widget.
    Ehm, have you ever heard of the DOCUMENTATION of Qt? Be tough and use the search inside Qt Assistant and try it with "style sheets".

    As a hint: the qproperty-fooBar option could be useful for you.


    EDIT: And by the way if you correct your typo (it is outset) your css works fine.

  3. #3
    Join Date
    Aug 2011
    Posts
    33
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    11

    Default Re: How do you set style sheets for various widgets?

    Well, fair enough, but I have been all over the documentation and, maybe it's just me, but I can't locate one place where all the properties/styles, and what they do, are listed for the various features and how they map to the different widgets, that is, what applies to one widget but not on another.

    You were also correct about my fumble-finger typo, and I did see the features expressed when I fixed that, but not as I would have hoped. I lost the background and foreground colors, and I don't think it's a typo, this time.

    Qt Code:
    1. bbStyle[0] = "color: aqua; background-color: black"
    2. "border-style: outset; border-color: green;"
    3. "border-width: 2px";
    4.  
    5. bbStyle[1] = "color: black; background-color: aqua"
    6. "border-style: outset; border-color: green;"
    7. "border-width: 2px";
    8. :
    9. :
    10. void BitButton::setState(int state)
    11. {
    12. bbState = state;
    13. this->setText(QString::number(state));
    14. this->setStyleSheet(bbStyle[state]);
    15. }
    To copy to clipboard, switch view to plain text mode 

    As you can see, what I'm looking for is a pushbutton that toggles its color every time it's pressed. I subclassed QBitbutton to do this. When I get the button to change color, the asthetics are lacking. When I add some dimension, I lose the color. I remember reading in the docs that some of these properties conflict, but it wasn't clear to me which ones, which is why I'm looking for a table or list that explains these things.

Similar Threads

  1. Style Sheets
    By yakuzan in forum Newbie
    Replies: 5
    Last Post: 29th May 2010, 10:11
  2. Do Qt Style Sheets support List-style-image?
    By daiheitan in forum Qt Programming
    Replies: 6
    Last Post: 12th March 2010, 02:41
  3. style sheets
    By alisami in forum Qt Programming
    Replies: 8
    Last Post: 7th May 2009, 10:41
  4. Qt style sheets
    By locus in forum Qt Programming
    Replies: 5
    Last Post: 5th April 2007, 18:03
  5. style sheets
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2007, 16: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
  •  
Qt is a trademark of The Qt Company.