How to set up slots for QXmpp signals
-
I would like to have some way for my MainWindow to get a signal when the QXmppClient class gets an error/is connected (for example). Preferably, I would not like the MainWindow to inherit the QXmppClient class ~ I want to have a split implementation of this class.
-
Hi
Make sure that the client is allocated BEFORE you
do the connect line.So before the connect, you should have something like
client = new QXmppClient(this);
-
You do not inherit from QXmppClient in order to use it.
QXmppClient already provides straightforward signals to indicate it is connected, disconnected, or in some error state. It also issues signals when messages are received. Just connect these signals to suitable slots in your QMainWindow sub-class. Your QMainWindow class does not need to own the QXmppClient object, and these signal connections can be made from outside, e.g. in main().
-
@ChrisW67 I suppose the issue lies in this line?:
connect(client, &QXmppClient::connected, this, &MainWindow::isconnected);
Where client is QXmppClient. This line appears in the constructor of the MainWindow class.
EDIT: Just for more clarification, this 'client' is type Client, and type Client inherits from QXmppClient. I know I don't have to, but please bare with me. Now I want to use the QXmppClient signals in the MainWindow class.
-
There is no issue with that line if the compiler is not complaining. You are using the signals from QXmppClient; a QXmppClient::connected() signal should result in your MainWindow::isconnected() code running.
What exactly is the problem that you are trying to solve?
-
Hi
Make sure that the client is allocated BEFORE you
do the connect line.So before the connect, you should have something like
client = new QXmppClient(this);