[Qt-interest] Would need some comments please

Gordon Schumacher gordon at rebit.com
Fri Nov 27 18:59:26 CET 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
Kari Laine wrote:
> Hi All,
>
> I am new to QT and quite new to C++ also so this is slow going. I am
> making Linux-program to Velleman PCSGU260 oscilloscope/Function
> generator.
>
> If I ever get this program done it will be under GPL 2 and later. So I
> am not after free consulting for a paid job.
>
> Anyway I would like to hear whether the structure of the user
> interface is stupid or not. My first stab was with single .h and .cpp
> file and that got too big. Now I have divided the program to separate
> classes but I am not sure it is the way it should be.

Yeah, definitely split it as one file per class, with the only
*possible* exception being when you have some little "utility" classes
that are tightly coupled (in which case also consider embedding them
in the main class).  I made that mistake once, with a QWizard, on the
rationale "hey, these classes are all inter-related"... and thus ended
up with a 2,000 line monster with thirteen different classes in it.
It rapidly becomes very difficult to find anything...

> Any comments highly appreciated - you don't have to be nice ... :-)))

In my experience "nice" and "productive" can be directly opposing... :)

Nitpick, but I personally have found it easier to group stuff like UI
layout to follow the object hierarchy, bottom-to-top, rather than
grouping types of operations.  For example, I'd do something more like
this:

QGridLayout *layout = new QGridLayout;

ch1Label = new QLabel("Volts/Div.");
ch1Label->setAlignment(Qt::AlignCenter);
layout->addWidget(ch1Label, 1, 2);

ch1Slider = new QSlider;
ch1Slider->setMinimum(0.01);
ch1Slider->setMaximum(100);
layout->addWidget(ch1Slider,1,1,20,1);


The other thing I can advise - again from having made this error - is
that you should have separate classes for the UI and what it does.  If
you've used Designer, it pretty much enforces that model.  I
personally find Designer more of an encumbrance than a help, but the
general idea of what it produces is right: the class it generates is
purely UI code, and you implement what the UI interactions *do* in a
separate class.

> Now I will start studying the QPainter - pointers to examples appreciated.

Consider QGraphicsView, particularly if you're going to end up with
any user-interactive stuff on the "display screen".  The
coordinates-in-coordinates hierarchy is decidedly confusing, but it is
hugely more powerful than just QPainter.  (If you're doing a o'scope
or logic analyzer, I'm particularly thinking of stuff like trigger
points and guide lines and the like.)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.12 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
 
iEYEARECAAYFAksQE34ACgkQ2yRp4mXKHF3PgwCgi5WgZ7vrWAxsMhuBI+iY7tOQ
UPEAni73oeFWKvH/NtuORMqrRa1OA4pH
=HKwA
-----END PGP SIGNATURE-----




More information about the Qt-interest-old mailing list