Signal and slot problem
-
@mrjj that's seems to be a problem but if i change my ISR()
void gpio::ISR() { gpio* GPIO=new gpio; if(gpio::isHIGH()) { qDebug()<<"RISING Interrupt called"; GPIO->emit_RisingSignal(); } else if(gpio::isLOW()) { qDebug() <<"FALLING edge"; GPIO->emit_FallingSignal(); } } i have the same problem, it didn't solve the problem/
-
but why are u creating a new Object???
Use the one in/from main.That is the one you have connect to mains slots so making a new one
in that function will not send any signals to main as you do not connect it
like the other one.So just newing the local copy instead, will not make any difference :)
-
@mrjj Sir, ISR() is a static function. So to access other functions of the class i need to create an object :) thats why i have defined two other function emit_RisingEdge() and emit_FallingEdge() so i can emit my signals independent of any object.
-
Hi,
Just one thing, you have now a memory leak.
But in any case, I must say I don't see any reason for making all these methods static.
-
-
@azravian In this case you could add a public static method to get the pointer to the gpio instance (basically you create a singleton):
class gpio : public QObject { Q_OBJECT public: gpio(): instancePtr(nullptr) {} static gpio* instance() { if (!instancePtr) instancePtr = new gpio(); return instancePtr; } private: gpio* instancePtr;
You can use this method in main to setup the connection and in static methods in gpio to get the pointer to the instance. Don't forget to delete the instance later.
-
-
Silly question but are you user the label is visible ? Do you have something on it before you call inserted ?