[Qt-creator] How does QtCreator support the "private" signals of e.g. QAbstractItemModel

Nikolai Kosjar nikolai.kosjar at digia.com
Fri Aug 30 13:40:14 CEST 2013

On 08/30/2013 11:06 AM, Milian Wolff wrote:
> Hey there!


> I'm wondering how you guys decided for QtCreator to support the "private"
> signals of QAbstractItemModel, such as "rowsAboutToBeInserted". They are
> declared in a section guarded by:
> #if !defined(Q_MOC_RUN) && !defined(qdoc)
> private: // can only be emitted by QAbstractItemModel
> #endif
> Do you guys define either of these macros while parsing the code? Or do you
> special-case these somehow to still support them as "proper" signals during
> code completion in a connect() statement?

Short answer: There is no special support.

Longer answer:

We don't define such macros while parsing, it's just that completion 
proposals are not limited with respect to the access modifiers and 
according to [0] this was done by design. Usually the access modifier is 
encoded in the icon of an completion entry (e.g. member completion). For 
emitting signals, it's a single icon without any hint on the access 
level (maybe that's because "Q_SIGNALS" and "signals" are defined to 
"public" by default). For completion within "connect(a, SIGNAL(" there 
is not even an icon column (I'm not sure what the reasoning is behind 
that, if there is any).

Note that things changed a bit with Qt5 (QAbstractItemModel again):

// Qt 5
     void rowsAboutToBeInserted(const QModelIndex &parent, int first, 
int last
#if !defined(Q_QDOC)
       , QPrivateSignal

See also [0]. We do hide the "QPrivateSignal" last parameter for 
"connect(a, SIGNAL(" completions.


[0] https://bugreports.qt-project.org/browse/QTCREATORBUG-1510
[1] http://woboq.com/blog/how-qt-signals-slots-work-part2-qt5.html , 
especially the section "Protected, Public, or Private Signals."

More information about the Qt-creator mailing list