Barry Roberts wrote:
And even some of us with only a mild distaste for C++ find Qt
unattractive because you don't REALLY write C++. At least the last
time I checked, you wrote in a very C++-like language that moc
pre-processed to C++. That gave me a rash. I can understand why they
did it, but I would argue that it's not C++.
That's a common misconception. The moc does not actually translate
anything. All the Qt code you write is honest-to-goodness compilable
C++. The moc generates companion C++ files that get built and linked in
to your executable by parsing your C++ code and looking for keywords
like "signals:" and "slots:". The terms "signals" and "slots" are
actually pre-processor defines that are defined to nothing.
For example. Here's a QObject-derived class:
class MyObject : public QObject
{
Q_OBJECT
public:
MyObject(QObject *parent=0);
public slots:
void mySlot();
signals:
void mySignal();
}
In this case, Q_OBJECT is a macro that expands to some code needed by
QObject to enable signals and slots. The term "slots" and "signals" are
both macros that expand to nothing.
The moc will come in and see the word "slots" and "signals" and generate
a file called moc_MyObject.cxx and is also compilable C++ code, which
contains all the signal and slot handling code.
Be it known that Qt *is* C++. There is no language translation at all.
I've been hacking Qt code for about 4 years, and I love it. I highly
recommend it for any GUI project. I even use it on the server-side
because it provides such a rich framework of functionality. Everything
from regex to strings to sockets.
--Dave
/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/