View Full Version : Signal-Slot, object instances

16th February 2006, 17:25
I am using a designer..and I was curious whether one could make a signal slot connection without making a instance of a object but declaring a object..

MyObj *obj;

obj=new MyObj();

just curious whether this would be valid

16th February 2006, 17:46
What actually do you mean?
In designer genearated files i never see something like that :rolleyes:

16th February 2006, 17:57
Well in designer you don't actually have the
MyObj *obj;

it is written at the public member Object explorer.
Now, generally before using the object we need to create a instance for it..I am asking can we use the object without creating its instance in a signal slot connection ..and what may its consequences be.

16th February 2006, 19:08
MyObj *obj;

This will crash.

You are passing an uninitialized pointer to connect(). If you're lucky obj is initialized with 0 and connect() checks for 0-pointers, but generally accessing an uninitialized object is simply shooting yourself in the foot.