Connecting 2 different classes together
Hello, I am trying to send a signal from one class to another class. For this, I am using a connect line such as this:
Code:
USB *USBInstance = new USB;
connect(this,
SIGNAL(sendChosenComPort
(QString)),USBInstance,
SLOT(receiveChosenComPort
()));
But after I add these lines, when I run, "The program has unexpectedly finished." error appears.
Then I tried to add
to the header file and
Code:
USBInstance = new USB()
to cpp. file. But again that gives an error. How can I connect 2 different classes in order to send a signal? Thanks beforehand.
P.S: I am a total newbie to QT, so please explain it accordingly :(.
Re: Connecting 2 different classes together
Quote:
Originally Posted by
GunkutA
But after I add these lines, when I run, "The program has unexpectedly finished." error appears.
This is usually the result of using a pointer that is not initialised (a run time C++ issue and not a compilation issue). There's not enough of your code here to make the problem obvious.
If removing both lines removes the problem then a guess would be that the constructor of the USB object is failing.
If removing only the connect() call removes the problem then my guess is the USBInstance variable here is uninitialised ( probably not the same USBInstance as you created), or the slot is called and does something with an invalid pointer.
Run your program your in debugger and let it crash. You should be able to see a backtrace leading from the point of failure back into your code. Inspect that back trace and inspect variable involved for clues.