[Qt-interest] Connect checkbox states

Christian Lackas delta at lackas.net
Tue Jun 16 15:34:43 CEST 2009


Hi Everybody,

how can I connect the checkbox state changed signal to the respective
setter slot of a second checkbox?

I tried:

    connect(checkBox1, SIGNAL(stateChanged(int)),
            checkBox2, SLOT(setChecked(bool)));

which is incompatible, 

    connect(checkBox1, SIGNAL(stateChanged(int)),
            checkBox2, SLOT(setChecked(int)));

where setChecked(int) is no valid slot, and also

    connect(checkBox1, SIGNAL(stateChanged(int)),
            checkBox2, SLOT(setCheckState(Qt::Checked)));

which also produces a

    No such slot QCheckBox::setCheckState(Qt::CheckState)
    (since no slot, just a plain function)

Unfortunately, I cannot use toggled(bool)/toggle, since I also want to
connect checkBox2 to checkBox1 (they should be linked; at least
most of the time) and this then produces and endless loop of togglings
(amongst other problems).

Why is there no simple setChecked(int) or setCheckState(int) slot?
Am I missing something?

Christian

-- 
http://www.inviCRO.com Pre-clinical imaging analysis and software services
http://www.spect-ct.com Multi-Modality Molecular Imaging



More information about the Qt-interest-old mailing list