Results 1 to 12 of 12

Thread: stylesheet

  1. #1
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question stylesheet

    hi,
    I need to apply frameShadow and framestyle to QLabel in a qss file.How to do that?
    Plz help.
    Cheers,
    Phillip



    --- Please post the solution you got to solve your problem. It may help others.

  2. #2
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: stylesheet

    What seems to be the problem?
    If you don't know how to apply your style sheet implemented in qss file you should do like this
    Qt Code:
    1. QString labelStyle;
    2. QFile file(":/images/Styles/LabelStyle.qss");
    3. file.open(QIODevice::ReadOnly);
    4. labelStyle = file.readAll();
    5. file.close();
    To copy to clipboard, switch view to plain text mode 
    C++ & AMD forever

  3. #3
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: stylesheet

    Quote Originally Posted by THRESHE View Post
    What seems to be the problem?
    If you don't know how to apply your style sheet implemented in qss file you should do like this
    Qt Code:
    1. QString labelStyle;
    2. QFile file(":/images/Styles/LabelStyle.qss");
    3. file.open(QIODevice::ReadOnly);
    4. labelStyle = file.readAll();
    5. file.close();
    To copy to clipboard, switch view to plain text mode 
    I'm applying the qss as above u've asked. my problem is that i need to apply frameshadow:Sunken to QLable .
    How ll i apply thru qss file.
    my code inside qss file is as follows.

    QLabel
    {
    background-color: ash;
    color: black;
    font-family : MS Sans Serif;
    font-size : 8px;
    font-weight : normal;
    }
    Cheers,
    Phillip



    --- Please post the solution you got to solve your problem. It may help others.

  4. #4
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: stylesheet

    Quote Originally Posted by phillip_Qt View Post
    I'm applying the qss as above u've asked. my problem is that i need to apply frameshadow:Sunken to QLable .
    Why don't you just use QFrame::setFrameShadow (QFrame::Sunken) on your QLabel ?
    C++ & AMD forever

  5. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: stylesheet

    Am not sure if this will help -

    QLabel{ color: palette(shadow); }

    also have a look at frameshadow topic

  6. #6
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: stylesheet

    Quote Originally Posted by aamer4yu View Post
    Am not sure if this will help -

    QLabel{ color: palette(shadow); }

    also have a look at frameshadow topic
    Thanx aamer. But its nt working. can u suggest any more idea?
    Cheers,
    Phillip



    --- Please post the solution you got to solve your problem. It may help others.

  7. #7
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: stylesheet

    Quote Originally Posted by THRESHE View Post
    Why don't you just use QFrame::setFrameShadow (QFrame::Sunken) on your QLabel ?

    Hi. I applied in side qss file as

    QLabel
    {
    QFrame::setFrameShadow (QFrame::Sunken)
    }
    still same problem.
    Cheers,
    Phillip



    --- Please post the solution you got to solve your problem. It may help others.

  8. #8
    Join Date
    Jan 2006
    Posts
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: stylesheet

    Looks like you're out of luck in the sense that, by default, according to the docs:

    Since 4.3, setting a stylesheet on a QLabel automatically sets the QFrame::frameStyle property to QFrame::StyledPanel.
    Have you tried using a border? Something like:

    Qt Code:
    1. {
    2. border: 1px inset gray;
    3. }
    To copy to clipboard, switch view to plain text mode 

    Or something similar?
    Last edited by Shadowfiend; 25th April 2008 at 16:40. Reason: [code] does not, in fact, end with [/quote]

  9. #9
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: stylesheet

    aahhhh,,, u posted before me :P

    I played with the stylesheet example in the QtDemo and made the following changes in code -
    Qt Code:
    1. nameLabel->setFrameStyle(QFrame::StyledPanel);
    To copy to clipboard, switch view to plain text mode 

    and on running the application, i tried edit, and in the edit made the following change -
    Qt Code:
    1. /* Mark mandatory fields with a brownish color. */
    2. .mandatory {
    3. color: brown;
    4. border-width:2;
    5. border-style: inset;
    6.  
    7. }
    To copy to clipboard, switch view to plain text mode 


    finally something
    by the way, Philip, ur questions will make everyone expert in using stylesheets

  10. #10
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: stylesheet

    Quote Originally Posted by phillip_Qt View Post
    Hi. I applied in side qss file as

    QLabel
    {
    QFrame::setFrameShadow (QFrame::Sunken)
    }
    still same problem.
    It may sound rude but are you familiar with Qt style sheets and Qt itself ?
    What I wrote means that you should literally write in your program code. For instance
    Qt Code:
    1. QLabel myLabel;
    2. myLabel.setFrameShadow (QFrame::Sunken);
    To copy to clipboard, switch view to plain text mode 
    I hope it helps
    C++ & AMD forever

  11. #11
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: stylesheet

    Quote Originally Posted by aamer4yu View Post
    aahhhh,,, u posted before me :P

    I played with the stylesheet example in the QtDemo and made the following changes in code -
    Qt Code:
    1. nameLabel->setFrameStyle(QFrame::StyledPanel);
    To copy to clipboard, switch view to plain text mode 

    and on running the application, i tried edit, and in the edit made the following change -
    Qt Code:
    1. /* Mark mandatory fields with a brownish color. */
    2. .mandatory {
    3. color: brown;
    4. border-width:2;
    5. border-style: inset;
    6.  
    7. }
    To copy to clipboard, switch view to plain text mode 


    finally something
    by the way, Philip, ur questions will make everyone expert in using stylesheets
    Thank u aamer.
    I'm a new bee in Qt. So really im intrested to learn from u peopls.
    Cheers,
    Phillip



    --- Please post the solution you got to solve your problem. It may help others.

  12. #12
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: stylesheet

    I am neither an expert, I too learn from such postings.
    believe me, i didnt knew the answer i had to search, glad i learned something new too.

Similar Threads

  1. Styling QComoBox using CSS Stylesheet
    By bjoernbg in forum Qt Programming
    Replies: 1
    Last Post: 6th October 2010, 23:12
  2. StyleSheet components using Qt designer
    By Kostanev in forum Qt Tools
    Replies: 1
    Last Post: 21st April 2008, 08:28
  3. how to apply stylesheet to qtopia application using qss file
    By namita in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 31st March 2008, 07:04
  4. Replies: 8
    Last Post: 17th March 2008, 14:04

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.