KTextEditor::ModificationInterface in connect
Daan De Meyer
daan.j.demeyer at gmail.com
Mon Aug 19 21:17:59 BST 2019
Hi,
I was trying to refactor some of the old Qt signal/slot usage in Kate
to the new syntax. However, when trying to refactor code using
`modifiedOnDisk` from `KTextEditor::ModificationInterface`, I'm
getting compilation errors that I'm not sure how to fix.
Before:
connect(doc, SIGNAL(modifiedOnDisk(KTextEditor::Document *, bool,
KTextEditor::ModificationInterface::ModifiedOnDiskReason)),
this, SLOT(documentModifiedOnDisc(KTextEditor::Document *, bool,
KTextEditor::ModificationInterface::ModifiedOnDiskReason)));
After:
auto interface = qobject_cast<KTextEditor::ModificationInterface *>(doc);
if (interface) {
connect(interface, &KTextEditor::ModificationInterface::modifiedOnDisk, this,
&KateFileTreeModel::documentModifiedOnDisc);
}
Compilation error highlights:
/usr/include/qt/QtCore/qobjectdefs.h: In instantiation of ‘struct
QtPrivate::HasQ_OBJECT_Macro<KTextEditor::ModificationInterface>’:
/usr/include/qt/QtCore/qobject.h:238:9: error: static assertion
failed: No Q_OBJECT in the class with the signal
238 |
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename
SignalType::Object>::Value,
| ^~~~~~~~~~~~~~~~~
Any ideas on how to use KTextEditor::ModificationInterface with the
modern Qt signal/slot syntax?
Regards,
Daan
More information about the KWrite-Devel
mailing list