User: Password:
|
|
Subscribe / Log in / New account

Clasen: Introducing GtkInspector

Clasen: Introducing GtkInspector

Posted May 19, 2014 13:41 UTC (Mon) by macson_g (subscriber, #12717)
In reply to: Clasen: Introducing GtkInspector by tristanb
Parent article: Clasen: Introducing GtkInspector

Factual errors:

> As it is, Qt adds some new keywords to C++ (`slot` and `signal` for example), which get replaced by macros by moc, which in turn get replaced by function calls by the preprocessor.

Nothing is 'replaced by moc', moc only generates a source file with meta-object code, and doesn't do any replacements in hand-written code. 'signals', 'slots' and 'emit' are simply _empty_ preprocessor macros (also available as Q_SIGNALS, Q_SLOTS, Q_EMIT), some of them used as markers by moc.

> signal.connect(sigc::bind(sigc::mem_fun(object, &Klass:func), closure));

Where does this ugliness come from? The documentation provides this example:

connect(lineEdit, &QLineEdit::textChanged, label, &QLabel::setText);

Which is so much easier and safer than GObject's version.

The example you provided looks like some ancient Boost.Signal invocation, which could look much better:

signal.connect(boost::bind(&Class:Function, instance, boundValue, _1)); // No C++11 needed!

But it has nothing to do with Qt.


(Log in to post comments)

Clasen: Introducing GtkInspector

Posted May 19, 2014 14:05 UTC (Mon) by mathstuf (subscriber, #69389) [Link]

> doesn't do any replacements in hand-written code. 'signals', 'slots' and 'emit' are simply _empty_ preprocessor macros

"signals" is "protected", IIRC. "slots" is empty since you preface it with a visibility keyword, e.g., "public slots".


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds