PDA

View Full Version : connect



mickey
26th May 2006, 23:16
Hi, I'd like to know if there's a way to do this below with ONE connect :


connect(buttonGroupLL, SIGNAL(clicked(int)), tabWidget3, SLOT(EnableTab(int)); //??enableTab?
connect(buttonGroupLL, SIGNAL(toggled(bool)), tabWidget3, SLOT(setEnabled(bool));

In other word: I've 3 checkBox that when they're clicked, they have to enable tab1,tab2,tab3 (tabs of tabWidget3).
Wich is the best way to do this? Thanks

luf
27th May 2006, 03:41
Several ways to achieve this
A) built on the code you wrote... to get one connect at last end...

1- create a custom signal from the groupbox that transmits an int
2- create a slot for each of the checkboxes in the groupbox that accepts a bool and emits the signal created above with correct int for the tabpage
3- create a custom slot on the tabwidget that enables/disables the page that the recieving int is.

this would make the checkboxes connected to the groupbox, the groupbox connected to the tabwidget and the tabpages get a signal from the tabwidget.

line drawing


Checkbox(bool) ----| |--- Tabpage(bool)
Checkbox(bool) ----|--- Groupbox(int) -- Tabwidget(int) ---|--- Tabpage(bool)
Checkbox(bool) ----| |--- Tabpage(bool)


B) easier. several connects :D

connect each checkbox to each tabpage directly


connect(checkbox1, SIGNAL(clicked(bool)), tabpage1, SLOT(setEnabled(bool)));
connect(checkbox2, SIGNAL(clicked(bool)), tabpage2, SLOT(setEnabled(bool)));
connect(checkbox3, SIGNAL(clicked(bool)), tabpage3, SLOT(setEnabled(bool)));

cheers,
leif

mickey
27th May 2006, 09:45
I don't understand first solution.This below is ok.
But I need also know wnen checkbox is toggled or not (to enable/disable tab widget)
This below send right number of tab to be enabled/disabled. But EnableTab don't know if must enble or disable....


connect(buttonGroupLL, SIGNAL(clicked(int)), tabWidget3, SLOT(EnableTab(int));