<table><tr><td style="">kossebau added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D24466">View Revision</a></tr></table><br /><div><div><blockquote style="border-left: 3px solid #8C98B8;
color: #6B748C;
font-style: italic;
margin: 4px 0 12px 0;
padding: 8px 12px;
background-color: #F8F9FC;">
<div style="font-style: normal;
padding-bottom: 4px;">In <a href="https://phabricator.kde.org/D24466#546952" style="background-color: #e7e7e7;
border-color: #e7e7e7;
border-radius: 3px;
padding: 0 4px;
font-weight: bold;
color: black;text-decoration: none;">D24466#546952</a>, <a href="https://phabricator.kde.org/p/dfaure/" style="
border-color: #f1f7ff;
color: #19558d;
background-color: #f1f7ff;
border: 1px solid transparent;
border-radius: 3px;
font-weight: bold;
padding: 0 4px;">@dfaure</a> wrote:</div>
<div style="margin: 0;
padding: 0;
border: 0;
color: rgb(107, 116, 140);"><p>Maybe Qt doesn't have any deprecated signals?</p></div>
</blockquote>
<p>That would be nice :) A few there are though, e.g. see here some for QComboBox, only using <tt style="background: #ebebeb; font-size: 13px;">QT_DEPRECATED_SINCE</tt> & <tt style="background: #ebebeb; font-size: 13px;">QT_DEPRECATED_VERSION_X</tt>, but not <tt style="background: #ebebeb; font-size: 13px;">QT_MOC_COMPAT</tt>:<br />
<a href="https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qcombobox.h.html#223" class="remarkup-link" target="_blank" rel="noreferrer">https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qcombobox.h.html#223</a></p>
<p>Perhaps people forgot about it, the macro also not being documented anywhere.</p>
<p>Now finally got around to do some test code to check deprecation with signal/slots:</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">#include <QObject>
#include <QCoreApplication>
#include <QDebug>
class Object : public QObject
{
Q_OBJECT
public Q_SLOTS:
Q_DECL_DEPRECATED
QT_MOC_COMPAT
void slotIt() {
qDebug() << "handling signal";
}
Q_SIGNALS:
Q_DECL_DEPRECATED
QT_MOC_COMPAT
void signalIt();
};
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
Object object;
QObject::connect(&object, SIGNAL(signalIt()), &object, SLOT(slotIt()));
QObject::connect(&object, &Object::signalIt, &object, &Object::slotIt);
emit object.signalIt();
return 0;
}
#include "main.moc"</pre></div>
<p>When building this gives:</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">main.cpp: In function ‘int main(int, char**)’:
main.cpp:29:40: warning: ‘void Object::signalIt()’ is deprecated [-Wdeprecated-declarations]
29 | QObject::connect(&object, &Object::signalIt, &object, &Object::slotIt);
| ^~~~~~~~
main.cpp:20:10: note: declared here
20 | void signalIt();
| ^~~~~~~~
main.cpp:29:68: warning: ‘void Object::slotIt()’ is deprecated [-Wdeprecated-declarations]
29 | QObject::connect(&object, &Object::signalIt, &object, &Object::slotIt);
| ^~~~~~
main.cpp:13:10: note: declared here
13 | void slotIt() {
| ^~~~~~
main.cpp:31:26: warning: ‘void Object::signalIt()’ is deprecated [-Wdeprecated-declarations]
31 | emit object.signalIt();
| ^
main.cpp:20:10: note: declared here
20 | void signalIt();
| ^~~~~~~~</pre></div>
<p>and when running just</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">handling signal
handling signal</pre></div>
<p>so no runtime warning about the compat signal or slot. Possibly as QT_NO_DEBUG is said to be defined for Qt release builds, so <tt style="background: #ebebeb; font-size: 13px;">check_and_warn_compat</tt> will not be run.</p>
<p>So having a _DEPRECATED with signal makes sense also for consumers connecting to the signal with memberfunction-pointer based connect. Will adapt the other patches accordingly.</p>
<p>Not sure what to do about the QT_MOC_COMPAT, so far it should not hurt to keep them, but the question is how useful adding new ones is and whether this is future-proof.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R263 KXmlGui</div></div></div><br /><div><strong>BRANCH</strong><div><div>deprecatedapi</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D24466">https://phabricator.kde.org/D24466</a></div></div><br /><div><strong>To: </strong>kossebau, Frameworks, dfaure, mlaurent<br /><strong>Cc: </strong>kde-frameworks-devel, LeGast00n, GB_2, michaelh, ngraham, bruns<br /></div>