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. Many Buttons but same process
Forum Updated to NodeBB v4.3 + New Features

Many Buttons but same process

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 970 Views 2 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.
  • Z Offline
    Z Offline
    zeroptr
    wrote on last edited by
    #1

    Hi All,

    At my project there are many QPushButton object at one page, I want to assign a ID to all push buttons and collect all slots at the same slot. But I have to realise which button is pressed on the slot function is there an easy way to achive it or should I have to write a fuction call to all buttons?

    Thanks...

    Linux Mint 20.04 64 Bit QT6.0.1

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You're likely looking for QSignalMapper

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • Z Offline
        Z Offline
        zeroptr
        wrote on last edited by
        #3

        Yes @SGaist that's what I'm looking for.. thanks..

        But seems that I have to write a new widget for this and I'll lose the comfort of QDesigner :(..

        You're great..

        Linux Mint 20.04 64 Bit QT6.0.1

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          No you don't, you only have to add some C++ code in your current widget to use that class.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            zeroptr
            wrote on last edited by
            #5

            I'll look at other samples to understand.. thank you..

            Linux Mint 20.04 64 Bit QT6.0.1

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              zeroptr
              wrote on last edited by
              #6

              Hi All,

              Who want's to use QSignalMapper with Qdesigner can add this code to initial of the class...

              TheMapper = new QSignalMapper(this);
              connect(TheMapper,SIGNAL(mapped(int)) , this,SLOT(GetCompProperties(int)));
              ui->vlfAlt_Cikis->connect(ui->vlfAlt_Cikis,SIGNAL(pressed()),TheMapper,SLOT(map()))
              TheMapper->setMapping(ui->vlfAlt_Cikis,1);

              //ui->vlfAlt_Cikis is a QPushButton...

              thanks @SGaist ...

              Linux Mint 20.04 64 Bit QT6.0.1

              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