Binary Compatibility Workarounds: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Add "cleanup" tag)
No edit summary
Line 3: Line 3:
[[Category:Developing_Qt]]
[[Category:Developing_Qt]]


= Binary Compatibility Workarounds =
This page describes some workarounds for keeping binary compatibility in patch releases. You should read the KDE reference: [http://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C++ Binary Compatibility Issues with C++].
 
This page describes some workarounds for keeping binary compatibility in patch releases.
 
You should read the KDE reference: http://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C++


== Declaring a slot for private classes (d-pointer) ==
== Declaring a slot for private classes (d-pointer) ==
Line 13: Line 9:
Use a Q_PRIVATE_SLOT:
Use a Q_PRIVATE_SLOT:


<code>
<code lang="cpp">
  class A: public QObject
  class A: public QObject
  {
  {
Line 31: Line 27:
Pitfalls to avoid:
Pitfalls to avoid:


''' Don't include `a.moc`, but `moc_a.cpp` in your .cpp file
* ''' 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
* Q_PRIVATE_SLOT takes the complete signature of the private slot, not just its name

Revision as of 08:22, 26 May 2015

This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine.
Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean.

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

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