Cheesy135
24th May 2020, 07:35
Hi All,
I feel like this should be simple I am just not sure what is going on.
I've got a ProgressUpdator function used to handle the signal updates of a progress bar:
#ifndef PROGRESSUPDATOR_H
#define PROGRESSUPDATOR_H
#include <QObject>
class ProgressUpdator : public QObject
{
Q_OBJECT
public:
explicit ProgressUpdator(QObject *parent = nullptr);
signals:
void updateProgress(int progress);
public:
void setProgress(int progress);
};
#endif // PROGRESSUPDATOR_H
with my .cpp file being:
#include "progressupdator.h"
ProgressUpdator::ProgressUpdator(QObject *parent) : QObject(parent)
{}
void ProgressUpdator::setProgress(int progress)
{
emit updateProgress(progress);
}
This is called from a class performing the algorithm
for (int i=0; i<100; ++i)
{
// Do work
progressUpdator->setProgress(i);
}
Any my .pro file has all files added to HEADERS and SOURCES as needed.
But this comes up with a undefined reference to setProgress().
If I try and get around this and put the contents of setProgress in the header file as an inline function the linker then complains that it cannot find the reference to updateProgress instead.
I've also tried running qmake and rebuilding but this doesn't make a difference.
Thanks in advance.
I feel like this should be simple I am just not sure what is going on.
I've got a ProgressUpdator function used to handle the signal updates of a progress bar:
#ifndef PROGRESSUPDATOR_H
#define PROGRESSUPDATOR_H
#include <QObject>
class ProgressUpdator : public QObject
{
Q_OBJECT
public:
explicit ProgressUpdator(QObject *parent = nullptr);
signals:
void updateProgress(int progress);
public:
void setProgress(int progress);
};
#endif // PROGRESSUPDATOR_H
with my .cpp file being:
#include "progressupdator.h"
ProgressUpdator::ProgressUpdator(QObject *parent) : QObject(parent)
{}
void ProgressUpdator::setProgress(int progress)
{
emit updateProgress(progress);
}
This is called from a class performing the algorithm
for (int i=0; i<100; ++i)
{
// Do work
progressUpdator->setProgress(i);
}
Any my .pro file has all files added to HEADERS and SOURCES as needed.
But this comes up with a undefined reference to setProgress().
If I try and get around this and put the contents of setProgress in the header file as an inline function the linker then complains that it cannot find the reference to updateProgress instead.
I've also tried running qmake and rebuilding but this doesn't make a difference.
Thanks in advance.