Binary Compatibility Workarounds

From Qt Wiki
Revision as of 13:43, 25 August 2017 by Ziller (talk | contribs) (Adapt to page move)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


This page describes some workarounds for keeping binary compatibility in patch releases. You should read the KDE reference: Binary Compatibility Issues with C++.

Specifically, the d-pointer technique is explained in much detail in D-Pointer: What Private Implementation is and how it works.

Declaring a slot for private classes (d-pointer)

Use a Q_PRIVATE_SLOT:

 class A: public QObject
 {
 Q_OBJECT
 
 private:
 Q_PRIVATE_SLOT(d_func(), void myPrivateSlot())
 };

/* in .cpp file */

 void APrivate::myPrivateSlot() {}

 #include "moc_a.cpp"

Pitfalls to avoid:

  • Don't include `a.moc`, but `moc_a.cpp` in your .cpp file
  • Q_PRIVATE_SLOT takes the complete signature of the private slot, not just its name