(C++) Qt class design

January 9, 2018 ยท View on GitHub

Qt class design is the correct design of Qt classes.

Qt class design should follow general class design.

  • Derive from QWidget [1]
  • If you need custom Signal Slots, add Q_OBJECT [1]
  • Check if the widget already exists [2]
  • Pick the right base class [2]
  • Decide on composite or draw [3]
  • Decide which signals to emit [3]
  • Decide carefully on types of signal parameters [3]
  • Decide on publishing internal states [4]
  • Decide which setter methods should be slots [4]
  • Decide on allowing subclassing [4]
  • Decide on parameters at construction time [5]
  • Keep the Qt convention [5]

References

  • [1] Qt Training: Widgets (part 3/3): Guidelines for Custom Widgets: Torsten Rahn, by basysKom YouTube
  • [2] Qt Training: Widgets (part 3/3): Guidelines for Custom Widgets: Torsten Rahn, by basysKom YouTube
  • [3] Qt Training: Widgets (part 3/3): Guidelines for Custom Widgets: Torsten Rahn, by basysKom YouTube
  • [4] Qt Training: Widgets (part 3/3): Guidelines for Custom Widgets: Torsten Rahn, by basysKom YouTube
  • [5] Qt Training: Widgets (part 3/3): Guidelines for Custom Widgets: Torsten Rahn, by basysKom YouTube