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. Full examples with New_Signal_Slot_Syntax
Forum Updated to NodeBB v4.3 + New Features

Full examples with New_Signal_Slot_Syntax

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 645 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.
  • ReneUafasahR Offline
    ReneUafasahR Offline
    ReneUafasah
    wrote on last edited by
    #1

    Hello Qt Community

    I was working through a simple example that uses the old Qt signal and slot macros:

    SIGNAL(), SLOT ()

    using the macros in params 2 and 4 in connect as follows:
    connect(
    sender, SIGNAL( valueChanged( QString, QString ) ),
    receiver, SLOT( updateValue( QString ) )
    );

    However, a lot of the documentation has no been updated to show us how to use examples using the new method, where the const * char parameters in positions 2 and 4 are replaced with the following

    connect(
    sender, &Sender::valueChanged,
    receiver, &Receiver::updateValue
    );

    Is there a more complete example that includes definition of the "PointerToMemberFunction" signal and method ?

    1 Reply Last reply
    0
    • ReneUafasahR ReneUafasah

      Yes, but the example in https://wiki.qt.io/New_Signal_Slot_Syntax is incomplete.

      How do you define Sender and Receiver as PointerToMemberFunctions

      connect(
      sender, &Sender::valueChanged,
      receiver, &Receiver::updateValue
      );

      J.HilkJ Online
      J.HilkJ Online
      J.Hilk
      Moderators
      wrote on last edited by
      #6

      @ReneUafasah

      assume you want to connect the textChanged signal from a QlineEdit with a QLabel

      QLineEdit *lineEdit = new QLineEdit(); //Sender Object/Instance
      QLabel *label = new QLabel();                //Receiver Object/Instance
      

      QLineEdit has the textChanged signal:
      QLineEdit::textChanged

      QLabel has the slot setText:
      QLabel::setText

      //connect(senderObject, pointer to signal, receiver, pointer to slot);
      connect(lineEdit, &QLineEdit::textChanged, label, &QLabel::setText);
      

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      3
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        What's wrong with the Qt documentation? What are you missing exactly?

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

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

          Hi
          Did you also see this ?
          https://wiki.qt.io/New_Signal_Slot_Syntax

          1 Reply Last reply
          1
          • ReneUafasahR Offline
            ReneUafasahR Offline
            ReneUafasah
            wrote on last edited by
            #4

            Yes, but the example in https://wiki.qt.io/New_Signal_Slot_Syntax is incomplete.

            How do you define Sender and Receiver as PointerToMemberFunctions

            connect(
            sender, &Sender::valueChanged,
            receiver, &Receiver::updateValue
            );

            Christian EhrlicherC J.HilkJ 2 Replies Last reply
            0
            • ReneUafasahR ReneUafasah

              Yes, but the example in https://wiki.qt.io/New_Signal_Slot_Syntax is incomplete.

              How do you define Sender and Receiver as PointerToMemberFunctions

              connect(
              sender, &Sender::valueChanged,
              receiver, &Receiver::updateValue
              );

              Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #5

              @ReneUafasah said in Full examples with New_Signal_Slot_Syntax:

              Yes, but the example in https://wiki.qt.io/New_Signal_Slot_Syntax is incomplete.

              Why

              How do you define Sender and Receiver as PointerToMemberFunctions

              What does this mean? sender and receiver are pointers to Sender and Receiver class. What else do you need to know here?

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              0
              • ReneUafasahR ReneUafasah

                Yes, but the example in https://wiki.qt.io/New_Signal_Slot_Syntax is incomplete.

                How do you define Sender and Receiver as PointerToMemberFunctions

                connect(
                sender, &Sender::valueChanged,
                receiver, &Receiver::updateValue
                );

                J.HilkJ Online
                J.HilkJ Online
                J.Hilk
                Moderators
                wrote on last edited by
                #6

                @ReneUafasah

                assume you want to connect the textChanged signal from a QlineEdit with a QLabel

                QLineEdit *lineEdit = new QLineEdit(); //Sender Object/Instance
                QLabel *label = new QLabel();                //Receiver Object/Instance
                

                QLineEdit has the textChanged signal:
                QLineEdit::textChanged

                QLabel has the slot setText:
                QLabel::setText

                //connect(senderObject, pointer to signal, receiver, pointer to slot);
                connect(lineEdit, &QLineEdit::textChanged, label, &QLabel::setText);
                

                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                1 Reply Last reply
                3
                • ReneUafasahR Offline
                  ReneUafasahR Offline
                  ReneUafasah
                  wrote on last edited by
                  #7

                  Thank you very much @J-Hilk .
                  That example helps.

                  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