Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to set up slots for QXmpp signals
Forum Updated to NodeBB v4.3 + New Features

How to set up slots for QXmpp signals

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 409 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    siya
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #5

      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);

      S 1 Reply Last reply
      1
      • C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #2

        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().

        1 Reply Last reply
        1
        • S Offline
          S Offline
          siya
          wrote on last edited by siya
          #3

          @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.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            ChrisW67
            wrote on last edited by
            #4

            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?

            1 Reply Last reply
            1
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #5

              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);

              S 1 Reply Last reply
              1
              • mrjjM mrjj

                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);

                S Offline
                S Offline
                siya
                wrote on last edited by siya
                #6

                @ChrisW67 @mrjj yes thank you, that was the issue (not allocating before making the connect line). Silly me - thank you for the help :)

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved