KTextEditor::ModificationInterface in connect

Christoph Cullmann christoph at cullmann.io
Tue Aug 20 08:04:02 BST 2019


On 2019-08-19 22:17, Daan De Meyer wrote:
> 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?

The modification interface is just an interface.
Perhaps that creates this error, thought not sure how to fix that 
properly.

Greetings
Christoph

> 
> Regards,
> 
> Daan

-- 
Ignorance is bliss...
https://cullmann.io | https://kate-editor.org


More information about the KWrite-Devel mailing list