Page 1 of 3 123 LastLast
Results 1 to 20 of 54

Thread: Still need help: Best way to have application "skins"?

  1. #1
    Join Date
    Feb 2008
    Posts
    153
    Thanks
    40
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Still need help: Best way to have application "skins"?

    What's the best way to have different "skins" for an application each with different effects and slightly different buttons. Is reimplementing the main class a solution? Or Can the QUILoader be used? (I'm afraid it might be a bit slow, and might not support multiple-inheritance)

    Anyways, if anyone could help out, that would be great

    Thanks in advance ~codeslicer
    Last edited by codeslicer; 22nd February 2008 at 22:36.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Best way to have application "skins"?

    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    codeslicer (23rd February 2008)

  4. #3
    Join Date
    Feb 2008
    Posts
    153
    Thanks
    40
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: Best way to have application "skins"?

    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

  5. #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: Best way to have application "skins"?

    Quote Originally Posted by codeslicer View Post
    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
    Qt Code:
    1. {
    2. background-image: url(:/images/Buttons_Styles/b_butt_free.png);
    3. border: none;
    4. }
    5. {
    6. background-image: url(:/images/Buttons_Styles/b_butt_over.png);
    7. border: none;
    8. }
    9. QPushButton:pressed
    10. {
    11. background-image: url(:/images/Buttons_Styles/b_butt_down.png);
    12. border: none;
    13. }
    14. QPushButton:disabled
    15. {
    16. background-image: url(:/images/Buttons_Styles/b_butt_disabled.png);
    17. border: none;
    18. }
    To copy to clipboard, switch view to plain text mode 
    And then use QWidget::setStyleSheet
    C++ & AMD forever

  6. The following 2 users say thank you to THRESHE for this useful post:

    codeslicer (22nd February 2008), spagatoni (25th March 2009)

  7. #5
    Join Date
    Feb 2008
    Posts
    153
    Thanks
    40
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: Best way to have application "skins"?

    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.

  8. #6
    Join Date
    Feb 2008
    Posts
    153
    Thanks
    40
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: Best way to have application "skins"?

    *bump*
    Anyone?

  9. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Best way to have application "skins"?

    What exactly is the effect you want to achieve?

  10. The following user says thank you to wysota for this useful post:

    codeslicer (23rd February 2008)

  11. #8
    Join Date
    Feb 2008
    Posts
    153
    Thanks
    40
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Talking Re: Still need help: Best way to have application "skins"?

    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

  12. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Still need help: Best way to have application "skins"?

    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.

  13. The following user says thank you to wysota for this useful post:

    codeslicer (23rd February 2008)

  14. #10
    Join Date
    Feb 2008
    Posts
    153
    Thanks
    40
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: Still need help: Best way to have application "skins"?

    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?

  15. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Still need help: Best way to have application "skins"?

    You can use the same classes. Just have a component which will be able to style other components.

  16. #12
    Join Date
    Feb 2008
    Posts
    153
    Thanks
    40
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: Still need help: Best way to have application "skins"?

    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?

  17. #13
    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: Still need help: Best way to have application "skins"?

    Quote Originally Posted by codeslicer View Post
    Oh, and when are style sheets going to be supported on Qt/Mac?
    They are already supported
    C++ & AMD forever

  18. #14
    Join Date
    Feb 2008
    Posts
    153
    Thanks
    40
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: Still need help: Best way to have application "skins"?

    Ok, that's good!

    But how do I use 2 seperate ui files in the same class? QUILoader? Sounds slow and looks like it doesn't support multiple inheritance...

  19. #15
    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: Still need help: Best way to have application "skins"?

    Quote Originally Posted by codeslicer View Post
    Ok, that's good!

    But how do I use 2 seperate ui files in the same class? QUILoader? Sounds slow and looks like it doesn't support multiple inheritance...
    I don't really understand what do you want to do. If you want to set style sheet to a widget in ui form just press right mouse button on it and select change style sheet and change it like on the screenshot
    Attached Images Attached Images
    • File Type: jpg 1.jpg (43.0 KB, 69 views)
    C++ & AMD forever

  20. #16
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Still need help: Best way to have application "skins"?

    Quote Originally Posted by codeslicer View Post
    But how do I use 2 seperate ui files in the same class?
    What do you intend to do? It makes no sense to load two different .ui's on a single widget, does it? You can use direct approach if you have two different widgets for which you want to load different forms. But by using direct approach you also lose a lot of flexibility. Then why not just wrap those two widgets as separate classes which both use single or multiple inheritance approach...
    J-P Nurmi

  21. #17
    Join Date
    Feb 2008
    Posts
    153
    Thanks
    40
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: Still need help: Best way to have application "skins"?

    Thanks for trying to help me. A lot. Maybe I explained myself wrong.

    I have this form with style sheets and custom buttons, setMask() enabled on some parts, etc. Then, I have a second form which doesn't use any of that, and uses the Operating System's Style. Now, at first, the "fancy" form is used for the program, but what if the user doesn't like it? Or what if somehow it doesn't work on his/her system? I want the user to be able to chose between using the "fancy" form and the "plain" one.

    If I want to have two different forms, with the "fancy" one containing different functions which would be used for setting effects, and the core functions, while the "plain" one will just have the core functions(functions which perform what the program is going to do, ie download and read a file), how would I approach that. Can I have two seperate classes, one which would use the form with the effects, then a seperate one which wouldn't use any effects at all?

    Is this possible?

  22. #18
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Still need help: Best way to have application "skins"?

    Wouldn't it be only a matter of removing style sheets, custom styles and/or masks (which ever you end up using)?
    J-P Nurmi

  23. #19
    Join Date
    Feb 2008
    Posts
    153
    Thanks
    40
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Post Re: Still need help: Best way to have application "skins"?

    Well, it's not as simple as myApp->removeStyle() or something like that.

    The "fancy" design is completely different, the only things that are the same are the object names...

  24. #20
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Still need help: Best way to have application "skins"?

    Quote Originally Posted by codeslicer View Post
    The "fancy" design is completely different, the only things that are the same are the object names...
    You mean like the form layout is completely different? I suppose you could use single inheritance approach and have two different ui members:
    Qt Code:
    1. #include "ui_plainwidget.h"
    2. #include "ui_fancywidget.h"
    3.  
    4. class MyFancyWidget : public QWidget
    5. {
    6. ...
    7. private:
    8. Ui::FancyWidget fancyUi;
    9. Ui::PlainWidget plainUi;
    10. };
    11.  
    12. void MyFancyWidget::setFancyMode()
    13. {
    14. saveFormState(); // you might want to store contents if you let user to change mode on the fly
    15. qDeleteAll(children()); // or something like this to clear everything, it is important to delete layout()
    16. fancyUi.setupUi(this);
    17. restoreFormState(); // restore contents
    18. }
    19.  
    20. void MyFancyWidget::setPlainMode()
    21. {
    22. ...
    23. plainUi.setupUi(this);
    24. ...
    25. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  25. The following user says thank you to jpn for this useful post:

    codeslicer (23rd February 2008)

Similar Threads

  1. dll + application
    By fpujol in forum Qt Programming
    Replies: 11
    Last Post: 15th April 2007, 18:37
  2. Application deployment problem
    By shapirlex in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 13th April 2007, 00:11
  3. Replies: 3
    Last Post: 8th December 2006, 18:51
  4. Replies: 3
    Last Post: 31st March 2006, 18:38

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.