qSignalMapper gets no output
I don't know why when I click the two radio buttons no text is output via QSignalMapper:
class:
Code:
private slots:
private:
void set_mappings();
Ui::SettingsWindow *ui;
constructor:
inside set_mappings() and clicked()
Code:
void SettingsWindow::set_mappings()
{
connect(ui->general_radio_backLightOff, SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(ui->general_radio_backLightOff,"general_radio_backLightOff");
connect(ui->general_radio_backLightOn, SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(ui->general_radio_backLightOn,"general_radio_backLightOn");
connect(mapper,
SIGNAL(mapped
(QString)),
this,
SIGNAL(clicked
(QString)));
}
void SettingsWindow
::clicked(QString text
) {
qDebug() << text;
}
Re: qSignalMapper gets no output
Radio buttons are usually used with the toggled(bool) signal. Then you won't need that signal mapper at all (it should work with the toggled() signal as well).
Re: qSignalMapper gets no output
Quote:
Originally Posted by
wysota
Radio buttons are usually used with the toggled(bool) signal. Then you won't need that signal mapper at all (it should work with the toggled() signal as well).
Negative.toggle takes boolean as input, which is not of the same type as for the map() slot.
The purpose I intended to use signalMapper is to get the value and object name of the radio button clicked, so accordingly I can call the relevant function or slot using the acquired values from mapper.
Re: qSignalMapper gets no output
there is no signal
mapped(QString)
Re: qSignalMapper gets no output
Quote:
Originally Posted by
amleto
there is no signal
mapped(QString)
you mind taking a look at the code above n tell me what exactly is wrong with it please. what is mapped(QString) ? there is so such slot n signal in the code.
Re: qSignalMapper gets no output
there is so such slot n signal in the code.
Yes there is.
you mind taking a look at the code above n tell me what exactly is wrong with it please.
You are trying to connect to the afore mentioned signal but there does not exist any such signal on signal mapper.
Re: qSignalMapper gets no output
Quote:
Originally Posted by
amleto
there is so such slot n signal in the code.
Yes there is.
you mind taking a look at the code above n tell me what exactly is wrong with it please.
You are trying to connect to the afore mentioned signal but there does not exist any such signal on signal mapper.
i'm confused, the signal you mentioned is a defined signal of qsignalmapper, which is connected to the clicked(QString ) signal.
Quote:
connect(mapper,SIGNAL(mapped(QString)),this,SIGNAL (clicked(QString)));
i don't know how this code shall be modified to get the output, could you show me please
Re: qSignalMapper gets no output
read the docs more carefully. It does not have the signal you are using - the signature is different (const QString & != QString).
Re: qSignalMapper gets no output
Quote:
Originally Posted by
amleto
read the docs more carefully. It does not have the signal you are using - the signature is different (const QString & != QString).
I did try, it fails:
Code:
void SettingsWindow::set_mappings()
{
connect(ui->general_radio_backLightOff, SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(ui->general_radio_backLightOff,"general_radio_backLightOff");
connect(ui->general_radio_backLightOn, SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(ui->general_radio_backLightOn,"general_radio_backLightOn");
connect(mapper,
SIGNAL(mapped
(const QString &)),
this,
SIGNAL(clicked
(const QString &)));
}
Re: qSignalMapper gets no output
well then I guess the only thing left to do is read my sig.
Re: qSignalMapper gets no output
Quote:
Originally Posted by
amleto
well then I guess the only thing left to do is read my sig.
that's not a good idea : (