Results 1 to 8 of 8

Thread: Another Question with StyleSheets

  1. #1
    Join Date
    Mar 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Another Question with StyleSheets

    I am now trying to allow users change the app's theme.A theme contains some PNG files and related *.qss files.
    The app will Open the current theme folder and read the correct QSS file to set styles for widgets.
    Now problem comes:
    In the QSS file ,my image URL use relative paths(That's a must,as theme designers can't get the path of the theme folder,so absolute path can not be used.)
    However,QT does not search for files in the QSS's folder ,but still search in the App's folder.So the resource files always can't be loaded.
    That really blocks me.

    Any reply,thanls

  2. #2
    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: Another Question with StyleSheets

    Once I faced this problem and solved it by using setPixmap("../user/yourfile.PNG"); from the source code.

  3. #3
    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: Another Question with StyleSheets

    A nice solution I use is: Everywhere you need the path to the folder write "%PATH%" (or something else) and when you chance your qss file, read all qss in a string, determinate the path to your qss folder at runtime (since it could be different on different platforms) and do a simple QString::replace() befor setting the qss.

  4. #4
    Join Date
    Mar 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Another Question with StyleSheets

    Thanks.In fact just a few minutes ago I solved this problem just like Lykurg did.I read the file into a QString and replaced all "url(./" to absolute Path.

    Another question:
    In Windows vista&7, the maximize,minimize and close button are put in a line and there 's no space between them.But when one button is hovered, the button has shadow.The most important is :the shadow is partly on the other buttons.

    In Qt,a QPushButton could also look different by using a PNG file(e.g: a shadow Button) as backgound-image when hovered.But,two widgets could not overlap each other.
    I wonder how to do it in Qt to create a group of vista-like buttons.

    Or anyone know how to create a Google Chrome-style UI?(No titleBar But has the windows control Buttons)?
    Still, waiting online for any reply.
    Last edited by daiheitan; 12th March 2010 at 08:31.

  5. #5
    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: Another Question with StyleSheets

    I would create a custom widget, handling all "buttons", and implement mouse press/release and do the drawing myself. (To detect hover use mouse move event)

  6. #6
    Join Date
    Mar 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Another Question with StyleSheets

    I just find QML,but not know that very much.
    Could QML handle this?

  7. #7
    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: Another Question with StyleSheets

    Sure it can, but it is also not that easy and you have to wait till summer when the stable version is shipped out. And as I understand the whole concept it is primary for interfaces with fixed sizes ==> mobile embedded devices...

  8. #8
    Join Date
    Mar 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Another Question with StyleSheets

    oops...
    I just tried Qt creator 2.0 Alpha,and it crashes a lot. Especially when using the Designer For QML.

    One more problem is (though I asked it in another post,but no good answer)
    Most programs use PNG file for buttons.And images of hover, normal,pressed states of a button are in just one PNG file.
    I wonder if there is a way in Qt style sheet to use a part of a PNG file.
    (I really wish there would be a way.....)

Similar Threads

  1. Where to put my stylesheets?
    By martinn in forum Qt Programming
    Replies: 3
    Last Post: 2nd February 2010, 15:28
  2. stylesheets and subcontrols
    By ctarsoaga in forum Qt Programming
    Replies: 2
    Last Post: 2nd February 2010, 08:19
  3. Stylesheets
    By FuryCradle in forum Newbie
    Replies: 2
    Last Post: 26th September 2009, 21:34
  4. stylesheets with RGB
    By tommy in forum Qt Programming
    Replies: 4
    Last Post: 13th December 2007, 01:02
  5. Problem mit Stylesheets
    By momesana in forum Qt Programming
    Replies: 1
    Last Post: 10th November 2006, 20:41

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.