Make event problem
-
Hi..
I try to make a custom event with 2 inputs, the code like this:in myclickevent.h:
@
#ifndef MYCLICKEVENT_H
#define MYCLICKEVENT_H#include <QObject>
#include <QEvent>class MyClickEvent : public QEvent
{
Q_OBJECT
public:
MyClickEvent(bool inspace, bool condition_on)
:QEvent(QEvent::User){}private:
bool inspc;
bool on;
};#endif // MYCLICKEVENT_H
@in myclickevent.cpp:
@
#include "myclickevent.h"MyClickEvent::MyClickEvent(bool inspace, bool condition_on):
QEvent(parent){
this->inspc = inspace;
this->on=condition_on;
}
@But there are error messages in .cpp file:
-
function "MyClickEvent::MyClickEvent(bool,bool)" already has a body,
see previous definition of {ctor} -
parent undeclared identifier
please help.
-
-
you should leave only one definition of your constructor
@
MyClickEvent(bool, bool)
@also, there no declaration of parent variable:
@
MyClickEvent::MyClickEvent(bool inspace, bool condition_on):
QEvent(parent)
@In fact, compiler reports you enough info about problems in your code.. What kind of help do you need?
-
Thanks for reply, I am still do not understand how to fix the error.
-
You need learn C++ before using Qt.
I'll try to prompt you
1st error: you have two implementations of MyClickEvent(bool, bool) constructor: one in .h file, another in .cpp file. You should lave only one of them.2nd error is about lines:
@
MyClickEvent::MyClickEvent(bool inspace, bool condition_on):
QEvent(parent)
@what is "parent" here?