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
    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
    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!
    That's a good point I didn't think of. Unfortunately those two ui members have nothing in common... How about introducing additional pointers to required objects (hopefully you don't have tons of them) so that you don't have to continuously check the mode and clutter your code with conditional blocks?
    Qt Code:
    1. class MyFancyWidget
    2. {
    3. ...
    4. private:
    5. Ui::FancyWidget fancyUi;
    6. Ui::PlainWidget plainUi;
    7.  
    8. QTextEdit* myTextObject;
    9. ...
    10. };
    11.  
    12. void MyFancyWidget::setFancyMode()
    13. {
    14. ...
    15. myTextObject = fancyUi.myTextObject;
    16. }
    17.  
    18. void MyFancyWidget::setPlainMode()
    19. {
    20. ...
    21. myTextObject = plainUi.myTextObject;
    22. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  2. The following user says thank you to jpn 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

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

    Great!! Thanks! It would take me several years to think of that one!

    Any chance I could create some for(int i=0; i<childWidgets().length(); i++) loop? Note that childWidgets() may not be an actual property, but for the sake of this question...

    So could I somehow apend that name? If it's not possible, it's ok.

    I don't need to do much, just a couple of buttons and a text box.

    Also, where would I put the connect()'s? In each of the plainUi and fancyUi functions, or in the constructor?

    Thanks a lot!

  4. #3
    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
    Any chance I could create some for(int i=0; i<childWidgets().length(); i++) loop? Note that childWidgets() may not be an actual property, but for the sake of this question...
    Do you mean something like:
    Qt Code:
    1. QPushButton* button = findChild<QPushButton*>("myButtonWithCertainObjectName");
    2. if (button) // just to assure it was found
    3. button->doSomething();
    4.  
    5. // or
    6.  
    7. QList<QPushButton*> allButtons = findChildren<QPushButton*>();
    8. foreach (QPushButton* button, allButtons)
    9. button->doSomething();
    To copy to clipboard, switch view to plain text mode 

    Also, where would I put the connect()'s? In each of the plainUi and fancyUi functions, or in the constructor?
    The whole GUI, including all widgets, gets re-created when you call respective setupUi(). So you must re-establish all signal-slot connections every time the "mode" is changed.
    J-P Nurmi

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

    codeslicer (24th 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
  •  
Qt is a trademark of The Qt Company.