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. Yet another questions about "go to slot" - #1 need an example adding / using signal parameters

Yet another questions about "go to slot" - #1 need an example adding / using signal parameters

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 5 Posters 779 Views
  • 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    I like to further improve my "connect" skill using "go to slot ".
    Have been trying to find ( asked Mrs Google ) an example of usage of "signal parameters".
    No success so far.

    void on_<object name>_<signal name>(<signal parameters>);

    Anybody can help me ?

    Here is "plain" "go to slot" function created in QDesigner using "go to slot " and selecting "SIGNAL " cliick(). Connecting using GUI to "SLOT " clear() works fine , but it does not show in the "on_(object)_(signal ) function .

    void TabWidget_Chat::on_pushButton_13_clicked()
    {

    }

    J.HilkJ CP71C 3 Replies Last reply
    0
    • S Offline
      S Offline
      stretchthebits
      wrote on last edited by stretchthebits
      #2

      You want to know what the function should look like for a button that gets pushed?
      Your on_pushButton_13_clicked() looks fine,
      In your TabWidget_Chat class, put
      private slots:
      void on_pushButton_13_clicked();

      and in your TabWidget_Chat constructor, allocate your button and then call:
      connect(THEBUTTON, &QAbstractButton::clicked, this, &TabWidget_Chat::on_pushButton_13_clicked, Qt::AutoConnection);

      1 Reply Last reply
      1
      • A Anonymous_Banned275

        I like to further improve my "connect" skill using "go to slot ".
        Have been trying to find ( asked Mrs Google ) an example of usage of "signal parameters".
        No success so far.

        void on_<object name>_<signal name>(<signal parameters>);

        Anybody can help me ?

        Here is "plain" "go to slot" function created in QDesigner using "go to slot " and selecting "SIGNAL " cliick(). Connecting using GUI to "SLOT " clear() works fine , but it does not show in the "on_(object)_(signal ) function .

        void TabWidget_Chat::on_pushButton_13_clicked()
        {

        }

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @AnneRanch said in Yet another questions about "go to slot" - #1 need an example adding / using signal parameters:

        I like to further improve my "connect" skill using "go to slot ".

        let me stop you right here.

        If you wan't to improve your "connect" skill than never ever use the connect by name feature -aka go to slot, when using Designer plugin.
        These types of connections are very brittle, as a simple object rename would break your code


        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
        4
        • A Offline
          A Offline
          Anonymous_Banned275
          wrote on last edited by
          #4

          BUMP
          ... an example of usage of "signal parameters".
          while using "go to slot :

          void on_<object name>_<signal name>(<signal parameters>);

          Anybody can help me ?

          mrjjM J.HilkJ 2 Replies Last reply
          0
          • A Anonymous_Banned275

            BUMP
            ... an example of usage of "signal parameters".
            while using "go to slot :

            void on_<object name>_<signal name>(<signal parameters>);

            Anybody can help me ?

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @AnneRanch

            Hi
            I'm not sure I understand what you are after.
            If you use Go to slot with a signal that has a parameter then it's added too.
            Like the Toggle signal that has a bool

            alt text

            gives

            void MainWindow::on_radioButton_3_toggled(bool checked)
            {
                
            }
            
            
            1 Reply Last reply
            4
            • A Anonymous_Banned275

              I like to further improve my "connect" skill using "go to slot ".
              Have been trying to find ( asked Mrs Google ) an example of usage of "signal parameters".
              No success so far.

              void on_<object name>_<signal name>(<signal parameters>);

              Anybody can help me ?

              Here is "plain" "go to slot" function created in QDesigner using "go to slot " and selecting "SIGNAL " cliick(). Connecting using GUI to "SLOT " clear() works fine , but it does not show in the "on_(object)_(signal ) function .

              void TabWidget_Chat::on_pushButton_13_clicked()
              {

              }

              CP71C Offline
              CP71C Offline
              CP71
              wrote on last edited by
              #6

              @AnneRanch
              Hi
              More in general.
              In ui you usually have controls that derive from QWidget then QObject.

              in .h of your UI
              protected slots:
              void MyRadioButton(bool)

              in .cpp of your UI
              So you can connect function to connect a signal of QWidget to your slot. so where you initialize your UI you can write
              connect( ui->MyRadioButton, &QRadioButton::toggled, this, &MyUiObject::MyRadioButton );

              void MyUiObject::MyRadioButton( bool value )
              {
              ...
              }

              Using "go to slot" is easy and fast but you could have a problem if you change the name of a control, you can compile the project but your old slot is no longer connect.

              1 Reply Last reply
              1
              • A Anonymous_Banned275

                BUMP
                ... an example of usage of "signal parameters".
                while using "go to slot :

                void on_<object name>_<signal name>(<signal parameters>);

                Anybody can help me ?

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #7

                @AnneRanch said in Yet another questions about "go to slot" - #1 need an example adding / using signal parameters:

                BUMP
                ... an example of usage of "signal parameters".
                while using "go to slot :

                void on_<object name>_<signal name>(<signal parameters>);

                Anybody can help me ?

                    void on_pushButton_13_toggled(bool checked);
                    void on_pushButton_13_clicked(bool checked);
                

                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
                1
                • A Anonymous_Banned275

                  I like to further improve my "connect" skill using "go to slot ".
                  Have been trying to find ( asked Mrs Google ) an example of usage of "signal parameters".
                  No success so far.

                  void on_<object name>_<signal name>(<signal parameters>);

                  Anybody can help me ?

                  Here is "plain" "go to slot" function created in QDesigner using "go to slot " and selecting "SIGNAL " cliick(). Connecting using GUI to "SLOT " clear() works fine , but it does not show in the "on_(object)_(signal ) function .

                  void TabWidget_Chat::on_pushButton_13_clicked()
                  {

                  }

                  CP71C Offline
                  CP71C Offline
                  CP71
                  wrote on last edited by
                  #8

                  @AnneRanch
                  Only another note
                  When you manually connect a control's signal to your slot don't use the same name of "go to slot" because else your slot will be called twice, once for "go to slot" mechanism and once for your connect.

                  e.g.
                  if you have a push button called on_pushButton_13 you musn't call your slot void on_pushButton_13_clicked(bool checked); if you use the connect function to manage clicked signal.

                  I hope I'm clear, no for you but for my english :(

                  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