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. Connect QButton :: pressed and send qobject::name + bool value (because toggle)
Forum Updated to NodeBB v4.3 + New Features

Connect QButton :: pressed and send qobject::name + bool value (because toggle)

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 299 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.
  • G Offline
    G Offline
    gfxx
    wrote on 20 Jan 2022, 14:25 last edited by
    #1

    In main windows I would insert 10 Qbutton (checkable) ... normally if connect on void we can use check state for make a if true/false function .... but I would use the same function for all toggle and pass the name of widget everytime is check to that function ... Need to reimplement QpushButton or there are a better and short way?

    regards
    bkt

    bkt

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 20 Jan 2022, 14:27 last edited by
      #2

      You can retrieve the sender() in the slot. Or use a lambda to pass the name (whatever this is and why it's needed) to the slot.

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

      G 1 Reply Last reply 22 Jan 2022, 15:07
      4
      • C Christian Ehrlicher
        20 Jan 2022, 14:27

        You can retrieve the sender() in the slot. Or use a lambda to pass the name (whatever this is and why it's needed) to the slot.

        G Offline
        G Offline
        gfxx
        wrote on 22 Jan 2022, 15:07 last edited by
        #3

        @Christian-Ehrlicher said in Connect QButton :: pressed and send qobject::name + bool value (because toggle):

        You can retrieve the sender() in the slot. Or use a lambda to pass the name (whatever this is and why it's needed) to the slot.

        thanks a lot ....

        QPushButton *btnOn = dynamic_cast<QPushButton*>(sender());
            QString pepperOn = btnOn->text();
        

        Is the right way? Any who it work.

        bkt

        C 1 Reply Last reply 22 Jan 2022, 15:09
        0
        • G gfxx
          22 Jan 2022, 15:07

          @Christian-Ehrlicher said in Connect QButton :: pressed and send qobject::name + bool value (because toggle):

          You can retrieve the sender() in the slot. Or use a lambda to pass the name (whatever this is and why it's needed) to the slot.

          thanks a lot ....

          QPushButton *btnOn = dynamic_cast<QPushButton*>(sender());
              QString pepperOn = btnOn->text();
          

          Is the right way? Any who it work.

          C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 22 Jan 2022, 15:09 last edited by
          #4

          @gfxx said in Connect QButton :: pressed and send qobject::name + bool value (because toggle):

          Is the right way?

          When using a dynamic cast (or object cast) the return value can be a nullptr - you should check for this.

          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
          2

          1/4

          20 Jan 2022, 14:25

          • Login

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