Results 1 to 5 of 5

Thread: How to decide whether to make a separate class for widgets of a window?

  1. #1
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default How to decide whether to make a separate class for widgets of a window?

    The main window contains a:

    • TODO list (text box), time allotted (list box), start time (text box).
    • Count down timer (timer), start button (button).


    I already have a class for the timer which contains few slots too.

    Remaining widgets have their objects declared in the main() currently.

    Now, I need to get the clicked item from the list and supply it to the timer.
    The way to do it is to create signal-slots.

    How to decide whether to make a separate class for widgets of a window or club them all together?

    Any design patterns here?

    Does MVP has anything to do with this "current case"?

  2. #2
    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: How to decide whether to make a separate class for widgets of a window?

    The decision is up to you. I personally would go for separate classes, because they are better manageable and maintainable. Then only do a "container" widget which layouts the custom widgets and do the signal and slot connections.

    If you mean model and view programming with MVP, then it has nothing to do with your question.

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

    TheIndependentAquarius (15th February 2012)

  4. #3
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default Re: How to decide whether to make a separate class for widgets of a window?

    Quote Originally Posted by Lykurg View Post
    Then only do a "container" widget which layouts the custom widgets
    What did you mean here, I didn't understand well. Please explain again.

  5. #4
    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: How to decide whether to make a separate class for widgets of a window?

    E.g. you have custom widgets A, B, C, and D which should have connections. Then make a QWidget W and in its constructor initiate ABCD, arrange them using e.g. QGridLayout and connect the signals and slots between ABCD.

    This way you only have to initiate W whenever you need ABCD inside your application.

  6. The following user says thank you to Lykurg for this useful post:

    TheIndependentAquarius (15th February 2012)

  7. #5
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default Re: How to decide whether to make a separate class for widgets of a window?

    Thanks.
    If I face some more problems I'll post back.

Similar Threads

  1. Put in a separate thread a method of a class
    By franco.amato in forum Qt Programming
    Replies: 0
    Last Post: 20th March 2010, 00:45
  2. separate class using an interface
    By qt_gotcha in forum Newbie
    Replies: 7
    Last Post: 3rd March 2010, 22:54
  3. Replies: 1
    Last Post: 7th December 2009, 08:26
  4. Accesing widgets from separate thread
    By msmihai in forum Qt Programming
    Replies: 2
    Last Post: 8th December 2008, 12:48
  5. separate Qt class diagram
    By juanrb in forum Qt Programming
    Replies: 2
    Last Post: 14th April 2008, 20:55

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.