Results 1 to 6 of 6

Thread: How to execute my .css file in Qt?

  1. #1
    Join Date
    Nov 2011
    Posts
    45
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default How to execute my .css file in Qt?

    Hi,
    I am having a .css file(with some button images and background image) instead of using style sheet and had added it to my project.

    I don't know how to link the .css file with my button image and background.

    If anyone knows how to add it please get me some sample or examples for it.



    Thanks in advance,
    Harish.M

  2. #2
    Join Date
    Oct 2007
    Location
    Lake Forest, CA, USA
    Posts
    132
    Thanks
    10
    Thanked 27 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: How to execute my .css file in Qt?

    Add your style sheet file to resource (.qrc), and then load it from there.
    Oleg Shparber

  3. #3
    Join Date
    Nov 2011
    Posts
    45
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: How to execute my .css file in Qt?

    Hi Oleg,

    I added my style sheet file to .qrc and still now it is not executing.
    What might be the error i had done help me to solve this..

  4. #4
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to execute my .css file in Qt?

    just adding is not enough. you can add whatever you want

    you have to set the style. read the content of your css file into a QString. then set this QString as Style to your application.

  5. #5
    Join Date
    Oct 2007
    Location
    Lake Forest, CA, USA
    Posts
    132
    Thanks
    10
    Thanked 27 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: How to execute my .css file in Qt?

    Quick snippet:
    Qt Code:
    1. QFile f(":/styles.qss");
    2. if (f.open(QIODevice::ReadOnly)) {
    3. qApp->setStyleSheet(QString(f.readAll()));
    4. f.close();
    5. }
    To copy to clipboard, switch view to plain text mode 
    Oleg Shparber

  6. #6
    Join Date
    Nov 2011
    Posts
    45
    Qt products
    Qt4
    Platforms
    Symbian S60

    Post Re: How to execute my .css file in Qt?

    Thank you everyone for your replies i will try it and let me see.

    It works fine thank you everyone
    Last edited by harish; 2nd December 2011 at 12:40.

Similar Threads

  1. Execute a .sql file with more than one query
    By ShadowBelmolve in forum Newbie
    Replies: 6
    Last Post: 19th August 2010, 16:48
  2. How to execute a QProgressDialog once
    By franco.amato in forum Newbie
    Replies: 4
    Last Post: 16th March 2010, 16:36
  3. cannot execute binary file
    By mgturner in forum Installation and Deployment
    Replies: 1
    Last Post: 16th March 2009, 17:04
  4. How to execute an exe file from Qt application
    By maveric in forum Qt Programming
    Replies: 1
    Last Post: 24th May 2008, 10:24
  5. Replies: 2
    Last Post: 5th March 2008, 10:39

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.