I have a problem with my Qt application. I'm trying to emit a signal from within another class (it is a nested class of the one in which the signal is placed).
I already connected the signal with a slot, which should be fine. But when I try to emit this signal from within this nested class I get the compiler error:
cannot call member function without object
What is wrong? I looked for that in Qt documentation but couldn't find reasonable solution or even explanation.
The simplified class definition looks as follows.
class LogWriter : public QDialog
{
Q_OBJECT
public:
class Log : public QObject
{
Q_OBJECT
public:
bool print;
Log(bool _print, QString _color, QObject *obj = NULL)
: QObject(obj)
{
print = _print;
color = _color;
}
};
LogWriter(QWidget * parent = 0);
~LogWriter();
public slots:
void setMinVal();
void setMediumVal();
void setHighVal();
void cleanWindow();
void appendText(QString &text);
signals:
void signalLogAppend(QString);
};
I connect the signal of an instance LOW
of the LogWriter in the client code to some slot using the following function call:
connect(&LOW, SIGNAL(signalLogAppend(QString)),
this, SLOT(appendText(QString&)),
Qt::DirectConnection);