[Qt-interest] two interfaces: gui, cl, inherit a QObject

Sean Harmer sean.harmer at maps-technology.com
Wed May 19 16:42:06 CEST 2010


On Wednesday 19 May 2010 15:14:56 Gabriele Kahlout wrote:
> > > I'm trying to have a ui Q_Object base that defines signals and slots
> > > both of my Window and CLInterface classes inherit, and re-implement.
> > > Window also needs to inherit QDialog. Yet I cannot, inherit from two
> > > qobjects. What do you suggest doing in this common scenario?
> > 
> > 1). We have no idea what you are trying to achieve from that description.
> > Please be more specific
> 
> Problem:
> Functionality provided by the system: X, Y.

That is not a description that is simply a pair of labels you have attached to 
the required functionality.

> Interfaces to the system: GUI, CL.

OK fine. So you wish to have a GUI or CLI interface. Is this within the same 
application or as two separate applications one with a GUI and one with CLI? 
It is easy to do as two applications just abstract the objects that do the 
actual work into a common library (shared or static) then create such an 
object in each of your applications. 

The CLI app will only be a few lines in a main() function that parse any cli 
arguments passed to your app, creates a QCoreApplication and an object from 
your library and starts the event loop (if it is needed).

The GUI app will be a little larger probably as it will need to instantiate 
some sort of UI that the user interacts with to configure your library object 
that does the actual work.

This way the graphical classes are only in the GUI application.

> > 2). You design sounds like a mess. Try listing your requirements and the
> > decomposing your system into classes with well-defined scopes. from the
> > above
> > it sounds like you want a class that does everything threading, dialogs,
> > command line interface.
> 
> Solution:
> UI base class of CL and GUI.
> UI signals: X, Y
> Controller object instantiates a GUI or CL, depending on deployment/user
> choice. It then binds the signals of the instantiated ui class to slots
> that perform functionality.
> 
> Is this poor design, with signals and slots? If so, please outline, as I've
> outlied mine above, your better solution.

The one thing that seems weird is how can you expect to have a UI class in a 
CLI application?

Cheers,

Sean



More information about the Qt-interest-old mailing list