[Qt-interest] Optionally deriving from QWidget

Andre Somers andre at familiesomers.nl
Fri Sep 16 07:55:19 CEST 2011


Op 15-9-2011 23:32, David Doria schreef:
> I have a class that emits Qt signals. I want to use this class in two 
> ways:
>
> 1) Interactive - I want to use this class as part of a Qt GUI 
> application that can handle the signals.
> 2) Non-interactive - I want to use this class in a command line 
> application that does not know about Qt.
>
I would choose a different approach:
1) Create a static library that contains all the business logic. This 
will be the heart of the application, but does not contain UI.
2) Create a thin application that uses this lib, and that provides the 
commandline version of the interface.
3) Create a simple GUI application that also uses the same lib, and that 
only provides the interactive UI.

I think that would be a much clearer code structure. It will saves you 
lots of hard to read #ifdefs.

André



More information about the Qt-interest-old mailing list