not a class, namespace, or enumeration??
So I have a class defined in a header file like so...
Code:
#ifndef TIMER_H
#define TIMER_H
#include <QObject>
{
Q_OBJECT
public slots:
void StartTimer();
signals:
void TimeOut();
};
#endif // TIMER_H
and what my main function does is simply create an instance of the timer class and make a connect with a signal from
a textedit object
Below is the main function
Code:
#include "window.h"
#include <QApplication>
#include "timer.h"
int main(int argc, char *argv[])
{
window w;
Timer t;
t::connect(w, SIGNAL(w::on_textEdit_textChanged()),t,SLOT(t::StartTimer()));
w.show();
return a.exec();
}
So can anyone explain why I get the error message "'t' is not a class, namespace or enumeration"?
Re: not a class, namespace, or enumeration??
t is an object name. Connect should look like :
Code:
QObject::connect(&w,
SIGNAL(on_textEdit_textChanged
()),
&t,
SLOT(StartTimer
()));
.
1 Attachment(s)
Re: not a class, namespace, or enumeration??
So I tried that and the reason why I had not done that was because I thought QObject was just a placeholder name for the actual object. My bad. However, the code still doesn't work. I still have lots of errors.
Attachment 13032
Also, I forgot to include the code for window.cpp and the timer.cpp. Here they are below...
window.cpp
Code:
#include "window.h"
#include "ui_window.h"
#include <QElapsedTimer>
#include <QTimer>
ui(new Ui::window)
{
ui->setupUi(this);
}
window::~window()
{
delete ui;
}
void window::on_textEdit_textChanged()
{
qDebug()<<"\nDEBUGGING";
}
void window::on_label_windowIconTextChanged()
{
qDebug()<<"\nHEEEELP!";
}
timer.cpp
Code:
#include "timer.h"
#include <QtDebug>
#include <QElapsedTimer>
void Timer::StartTimer()
{
qDebug()<<"Starting the timer!";
}
Re: not a class, namespace, or enumeration??
Please don't post screenshots of error messages, copy the actual text and post that. By and large, screenshots are mostly illegible and of little help if you can't read them. And use CODE tags (see below) when posting source code.
From what I can read, it looks as though your project is not compiling the "moc" file produced when the MOC compiler processes the Timer.h header file. As a result, the symbols defined in that file are not being linked into the executable. Try manually running qmake (from the Qt Creator "Build" menu), then rebuild all.
Re: not a class, namespace, or enumeration??
As d_stranz said this looks like "missing moc run". Also check that your class declaration contains the Q_OBJECT marker.
Aside from that, your original connect doesn't make any sense given the new code you posted.
You are trying to connect a slot to a slot.
Cheers,
_
Re: not a class, namespace, or enumeration??
Ok. Sorry about the screenshot and thank you all for the help. For now my problem has been solved.