Binary Compatibility Workarounds: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
=Binary Compatibility Workarounds=
[[Category:Developing_Qt]]
 
= Binary Compatibility Workarounds =


This page describes some workarounds for keeping binary compatibility in patch releases.
This page describes some workarounds for keeping binary compatibility in patch releases.


You should read the <span class="caps">KDE</span> reference: http://techbase.kde.org/Policies/Binary_Compatibility_Issues_With_C++
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) ==


Use a Q_PRIVATE_SLOT:
Use a Q_PRIVATE_SLOT:


Pitfalls to avoid:
<code><br /> class A: public QObject<br /> {<br /> Q_OBJECT<br /> …<br /> private:<br /> Q_PRIVATE_SLOT(d_func(), void myPrivateSlot())<br /> };
 
* 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
 
===Categories:===


* [[:Category:Developing Qt|Developing_Qt]]
/* in .cpp file '''/
<br /> void APrivate::myPrivateSlot() {…}
<br /> #include &quot;moc_a.cpp&amp;quot;<br /></code>
<br />Pitfalls to avoid:
<br />''' Don't include `a.moc`, but `moc_a.cpp` in your .cpp file<br />* Q_PRIVATE_SLOT takes the complete signature of the private slot, not just its name

Revision as of 09:59, 24 February 2015


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++

Declaring a slot for private classes (d-pointer)

Use a Q_PRIVATE_SLOT:

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

/* in .cpp file '''/
<br /> void APrivate::myPrivateSlot() {…}
<br /> #include &quot;moc_a.cpp&amp;quot;<br />


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