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 connect QPushButton to a group of QPushButton with signal/slot
Forum Updated to NodeBB v4.3 + New Features

How to connect QPushButton to a group of QPushButton with signal/slot

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 751 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.
  • C Offline
    C Offline
    Calivernon
    wrote on last edited by
    #1

    Hi,

    I have 9 QPushButton corresponding to the 9 digits 1-9, and I have a board of QPushButton (without text), I would like to connect with signal/slot the 9 digits buttons to my board in order to write the digits on the board's buttons.

    So first I created a "normal" project without UI, I placed my buttons and used a QSignalMap to do that and it worked.
    But now I would like to do that using the UI but I don't succeed or I could connect all of my 9 digits to all of my board's buttons so would be 9 times 81 (=729) connections which is not sensible, so how can we do something like QSignalMapper with the designer?

    Thanks.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      michelson
      wrote on last edited by
      #2

      Why don't you just use the previous non-Ui solution withQSignalMapper pasting slightly modificated singnal mapping code after you call ui->setupUi(this)? Then you will have access to all these buttons and if you bundle your QPushButtons in one QButtonGroup (you can do it from QDesigner - select all buttons, right click and choose something like bundle to a new group - not sure if thats exactly that couse i have designer in my home language but i think you will get it) you can eaisly loop through them to map your signals.

      C 1 Reply Last reply
      1
      • M michelson

        Why don't you just use the previous non-Ui solution withQSignalMapper pasting slightly modificated singnal mapping code after you call ui->setupUi(this)? Then you will have access to all these buttons and if you bundle your QPushButtons in one QButtonGroup (you can do it from QDesigner - select all buttons, right click and choose something like bundle to a new group - not sure if thats exactly that couse i have designer in my home language but i think you will get it) you can eaisly loop through them to map your signals.

        C Offline
        C Offline
        Calivernon
        wrote on last edited by
        #3

        @michelson

        Hi, thanks,
        Yes I can write a QSignalMapper but I wanted to try that with QtDesigner.
        Actually I would like to write a digit on the board's buttons but only the selected ones.
        So I will try to group the buttons as you said.

        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