See Style Sheet Example.
codeslicer (23rd February 2008)
In one of my "skins", which is currently just a dialog, I use setMask and in the end have an irregulary shaped window. I have different event handlers which draw buttons which fade in and out when the mouse hovers over them. Then I want a plain skin which uses the system's window manager to do all the work. Does the QStyle class support this situation? Thanks so far though![]()
That's possible for hovering you should use styles like this
And then use QWidget::setStyleSheetQt Code:
{ background-image: url(:/images/Buttons_Styles/b_butt_free.png); border: none; } QPushButton:hover { background-image: url(:/images/Buttons_Styles/b_butt_over.png); border: none; } QPushButton:pressed { background-image: url(:/images/Buttons_Styles/b_butt_down.png); border: none; } QPushButton:disabled { background-image: url(:/images/Buttons_Styles/b_butt_disabled.png); border: none; }To copy to clipboard, switch view to plain text mode
C++ & AMD forever
codeslicer (22nd February 2008), spagatoni (25th March 2009)
Ok, how would I designate certain parts of the qlabel to react to hover? For example, if I have this image:
====
- [] x
====
And it's one big QLabel, how would I set different images depending on where the button was using Style Sheets? I want to do it like the HTML image maps.
Thanks in advance for any help
No help yet?
Last edited by codeslicer; 22nd February 2008 at 22:14.
*bump*
Anyone?
What exactly is the effect you want to achieve?
codeslicer (23rd February 2008)
Having different "skins" and forms in general. This is the situation:
I have an app which has a custom titlebar, buttons, and even a custom shape using QWidget::setMask(), but for platforms on which this wouldn't really fit in (IE Mac), I want the user to be able to "turn off" the skin and load a form which doesn't use any effects/custom titlebars and uses the default window decorations. Should I create two seperate QWidget classes, ie myApp() and myAppWithCoolSkin(), and check what option the user picked by checking QSettings before the widget is even initialized? That looks like it would involve copy and paste of the same code.
Any help will be appreciated. Thanks in advance, again![]()
As for everything but custom window shapes you can use a custom QStyle subclass and simply replace one style with another upon demand. As for custom shapes that you want to obtain through setMask() unfortunately you need to do the masking manually, thus you need to come up with a system of reading shapes from some configuration files and applying them to your widgets.
codeslicer (23rd February 2008)
Well, I don't really want a whole skin manager, just let the user pick between the stylish one and the plain one. I don't need to have different skin files and such, just let the user chose between the one with setMask() and buttons with effects, etc, and one which will try to fit as best as possible with the native platform.
Can I use different classes then? With the same code?
You can use the same classes. Just have a component which will be able to style other components.
Ok, but if I have 2 seperate .ui files, how would I declare them in the same class? All of my buttons, boxes, etc will still have the same object names, so I guess I don't really need to change the "core" of my program. Maybe, in the constructor, I should have an if() tag which should check QSettings if the app should load the new/old skin, and somehow load a different ui file based on that?
But I have a question. If I use the QUILoader class, is it slow? And does it support multiple inheritance? Thanks
Oh, and when are style sheets going to be supported on Qt/Mac?
Bookmarks