Hi,
I want to disable my button on the click of it ...so i wrote this but it doesnt seem to work...
i am surprised ..why ?Code:
connect(navigate->recordButton,SIGNAL(clicked()),this,SLOT(setDisabled(TRUE)));
Printable View
Hi,
I want to disable my button on the click of it ...so i wrote this but it doesnt seem to work...
i am surprised ..why ?Code:
connect(navigate->recordButton,SIGNAL(clicked()),this,SLOT(setDisabled(TRUE)));
arghh...i was using 'this' in the connect..my bad...
Didn't you receive an strange message when executing from Qt saying "cannot find SLOT setDisabled(TRUE)" ?
It may never work. Signal & Slot must have the same signature. Of course, these two methods have the same, but doesn't mean the same ( if is clicked but is not checked, setDisabled doesn't work as you want )
You can derive the QAbstractButton class, creating a new SLOT disableWhenPress ( bool Ignore ) and connect it like this :
connect(navigate->recordButton,SIGNAL(clicked()),this,SLOT(disableW henPress()));
And it may work...
Another way of achieving this, perhaps a simpler one, could be connecting the pressed signal to an slot that does some stuff ( if you press the button to take some action, you have to program that action, haven't you ? ) and on the first line you disable the button manually :
button->setDisabled(true)
no, and i shouldnt be recieving this message because there is a slot named setDisabled in QWidget .http://doc.trolltech.com/4.4/qwidget.html#setDisabledQuote:
Didn't you receive an strange message when executing from Qt saying "cannot find SLOT setDisabled(TRUE)" ?
i didnt understand what do you mean by that..:confused:Quote:
Of course, these two methods have the same, but doesn't mean the same ( if is clicked but is not checked, setDisabled doesn't work as you want )
I had already tried this way but this also did not worked..Quote:
connect(navigate->recordButton,SIGNAL(clicked()),this,SLOT(disableW henPress()));
This is very true but on the pressing of my button i am calling a different widget while as far button itself is concerned it is in a different widget ,so it is not true for my case....Quote:
Another way of achieving this, perhaps a simpler one, could be connecting the pressed signal to an slot that does some stuff ( if you press the button to take some action, you have to program that action, haven't you ? ) and on the first line you disable the button manually :
button->setDisabled(true)
THanks
First I've to say sorry. I've wrote my answer while you write you answered yourself and I didn't see the difference you said ( I mean the "this" error )
I think I haven't explained it very clear ( I don't speak/write English usually and perhaps that's the problem ).Quote:
i didnt understand what do you mean by that..:confused:
I want to say that connecting a signal with an slot both with the same "aspect" ( both take a boolean parameter ) is possible, but the meaning of that value perhaps is not the desired or expected.
And of course I didn't know that you can call an SLOT changing parameter's values as you do. I thought that was an error.
Thanks to you, as we say in Spanish "Nunca te acostarás sin saber una cosa más" ( You'll never go to bed without learning something ) ;)
As noted in the FAQ:
http://www.qtcentre.org/forum/faq.ph...ot_with_values