S
S
Slavka2016-03-31 15:36:37
Qt
Slavka, 2016-03-31 15:36:37

Does Qt map signal respond to everything at once?

QPushButton *pButton = new QPushButton("Запустить", ui->ViewData);
            ui->ViewData->setCellWidget(i, 7, pButton);

            connect(pButton,
                    SIGNAL(clicked()),
                    &ButtonSignalMapper,
                    SLOT(map()));

            ButtonSignalMapper.setMapping(pButton, i);

            connect(&ButtonSignalMapper,
                    SIGNAL(mapped(int)),
                    this,
                    SLOT(CellButtonClicked(int)));

            i++;

Here is part of the code for adding buttons to a cell in QTableWidget and trying to connect signals to them, but there was a problem, that if there are 8-rows => 8-buttons in the table, then it reacts 8 times.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Yakupov, 2016-04-08
@DeeplessHole

If I understand correctly, then you call this connect in a loop

connect(&ButtonSignalMapper,
                    SIGNAL(mapped(int)),
                    this,
                    SLOT(CellButtonClicked(int)));

thereby creating 8 bindings of the CellButtonClicked function on the ButtonSignalMapper.
Try to take this binding out of the loop.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question