This is how the declarations in the base class look:
protected:
void indexAll();
void cleanAll();
In the derived class the following does not compile:
indexAll(); // OK
connect(&_timer, &QTimer::timeout, this, &FileIndex::indexAll); // ERROR
connect(&_timer, SIGNAL(timeout()), this, SLOT(indexAll())); // OK
I would like to use the first variant of connect
, since it does some compile time checks. Why is this returning the error:
error: 'void Files::FileIndex::indexAll()' is protected
void FileIndex::indexAll()
^
[...].cpp:246:58: error: within this context
connect(&_timer, &QTimer::timeout, this, &FileIndex::indexAll);
^
The 'old' style syntax works because signal emission runs through qt_static_metacall(..)
which is a member of FileIndex
and so has protected access.
The 'new' style syntax does work, but for this reason won't let you take the address directly of the parent class method. It will however take the 'inherited' address of indexAll()
, so just change the code to:
connect(&_timer, &QTimer::timeout, this, &Derived::indexAll);