Results 1 to 20 of 54

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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.

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

    codeslicer (23rd February 2008)

  3. #2
    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?

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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.

  5. #4
    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?

  6. #5
    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

  7. #6
    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...

  8. #7
    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

  9. #8
    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

  10. #9
    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?

  11. #10
    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

  12. #11
    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...

  13. #12
    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

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

    codeslicer (23rd February 2008)

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

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

    Thanks! Only one question. Later in my code, the "core" of it, how would I refer to the objects on my forms, if they have the same names? Do I have to use plainUi.myTextBoxObject, or can I just ise myTextObject like in multi-inheritance? Thanks again!

  16. #14
    Join Date
    Sep 2007
    Location
    Szczecin, Poland
    Posts
    153
    Thanks
    7
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

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

    You may use QStyle and make usage of polish() / unpolish() methods to set/unset masks etc.
    It would be more flexible when you'll be adding more styles in future (u have all style stuff in single class & you don't have to remember about changes in lots of places in entire application code).

    I'm using single style for skins effect that gets images path in constructor and styleplugin searches skins directory and creates an instance of the same style for different images set.
    It causes that adding new skins doesn't require coding, just some painting job.
    See GrEEn (Graphics Effects Environment)
    http://sourceforge.net/project/platf...roup_id=232746
    a qt-based plugins oriented MDI image processing application(contains also qt plugins like styles & imageformats).

  17. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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"?

    Quote Originally Posted by codeslicer View Post
    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?
    You can also have a common base class with objects common to the two "modes" and two subclasses - one "plain" and one "fancy".

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

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

    @wysota - maybe I don't get it, but the buttons, textboxes, labels, etc are children of each of the respective forms.

    @jpn - by loop I meant instead of having to use:
    Qt Code:
    1. void MyFancyWidget::setFancyMode()
    2. {
    3. myTextObject = fancyUi.myTextObject;
    4. myButtonObjectt = fancyUi.myButtonObject;
    5. }
    6.  
    7. void MyFancyWidget::setPlainMode()
    8. {
    9. ...
    10. myTextObject = plainUi.myTextObject;
    11. myButtonObject = plainUi.myButtonObject;
    12. }
    To copy to clipboard, switch view to plain text mode 

    I could use:
    Qt Code:
    1. for(int i=0; i<fancyUi.children().size(); i++) {
    2. childrenList[i]
    3. }
    To copy to clipboard, switch view to plain text mode 
    I don't really know how to make this, but what I'm trying to do is to dynamically convert all of fancyUi's children into names which wouldn't require prefixing fancyUi.

    Or, could I use this?
    Qt Code:
    1. using namespace fancyUi
    To copy to clipboard, switch view to plain text mode 

    But this has to be globally declared right? I can't put it in each of the mode-changing functions can I? What I'm trying to do is somehow "fake" the multi-inheritance approach from single inheritance to make life easier. I can make pointers to each single object, but as my program grows this looks like it would involve lots of unneeded code.

    Thanks!

  19. #17
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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"?

    Quote Originally Posted by codeslicer View Post
    @wysota - maybe I don't get it, but the buttons, textboxes, labels, etc are children of each of the respective forms.
    So where is a problem with that?

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

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

    Those widgets(buttons, text boxes) are contained in different layouts which have skins, therefore I can't remove those layouts without disrupting the children.

    Please read my post above. ^

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.