How would it be possible to make a button not aceept clicks?
I have clicked it once and set an icon to it..and now I don't want to disable it(because icon goes grey >.<),but I want to keep it enabled,with no clicks..
Thank you.
How would it be possible to make a button not aceept clicks?
I have clicked it once and set an icon to it..and now I don't want to disable it(because icon goes grey >.<),but I want to keep it enabled,with no clicks..
Thank you.
You can disconnect or block signals.
"BumbleBee" (25th March 2011)
Yeah,I disconnected it!
Thank you.
Just a note - that sort of behavior has the potential to be very frustrating to users. Clicking a button that looks and behaves as if it is active and having it do nothing indicates that something isn't right, that the program has failed in some way.
I'd suggest changing the button's appearance in some way to indicate that it has fulfilled its one-shot role.
That's a call you'll have to make for yourself. There are always exceptions. As a general rule, though, it's often a bad idea to tinker with normal GUI behaviors.
Hey guys,how can I check for winner?
I cannot check,because buttons have no value(or sth..)..so I'd do: if(btn[0] == x && btn[1] == x && btn[2] == x )
Thank you.
There are several approaches. First, you can derive a trivial extension of QPushButton that can be assigned a value depending on state, row and column or whatever.
Better would be to completely sever any connection between application logic and application UI, and have the buttons manipulate some underlying data structure that ultimately drives game logic. This makes it easy to replace the UI with a different one while leaving the rest of the program unchanged. For more information, look up the "Model/View/Controller".
you can use setProperty to set a "x" and "0" and access it by callling propertyI cannot check,because buttons have no value(or sth..)
it will be like ,
when you set property
btn[0]->setProperty("marked",false);
when you access, if(btn[0]->property("marked").toBool())
hope it helps
bala
Last edited by BalaQT; 26th March 2011 at 16:15. Reason: ex code added
My code is:
Qt Code:
if(btn[0]->property("x").toBool() && btn[1]->property("x").toBool() && btn[2]->property("x").toBool()) //msgBox here.;To copy to clipboard, switch view to plain text mode
And it gives a bug,when I press any btn,the msg appears(i mean without completing a line of Xs..it skips everything on first click....)
I'm not sure, but may be u should try
Qt Code:
if(btn[0]->property("x").toBool()==true && btn[1]->property("x").toBool()==true && btn[2]->property("x").toBool()==true)To copy to clipboard, switch view to plain text mode
@Archa4: it does not make any difference, "true==true" and "false==true" evaluates to "true" and "false" respectively
Show the code where you assign the "x" property, maybe you set it to "true" for all the buttons.
hi, bumblebee
as stampede mentioned, you need to check your logic,
its the logical issue.And it gives a bug,when I press any btn,the msg appears
post setProperty code here
bala
Well I did what BalaQT said,but I know realised that I didn't put the false after text...does it change things?
yes, that will correct your problem. if you still not able to solve the problem, post the setProperty code here.I know realised that I didn't put the false after text.does it change things?
bala
Well,no I still get the bug...
The code is:
Qt Code:
{ x->disconnect(); x->setProperty("x",false); //here is set it to x,false lbl->setText("<b>Turn : Player 2</b>"); turn = false; } bool TicTacToe::winX() //this function is called to every btn as well and checks for winner { if(btn[0]->property("x").toBool() && btn[1]->property("x").toBool() && btn[2]->property("x").toBool()) { btn[0]->setText("x won 1"); //here is the bug,although i did click only btn[0],the winner text has appeared.... for(i; i < 9; i++) btn[i]->disconnect(); return true; }To copy to clipboard, switch view to plain text mode
"x" is an existing property name. Use something that doesn't exist, like:
Qt Code:
button->setProperty("I need to read Qt documentation more", true);To copy to clipboard, switch view to plain text mode
Can someone tell me,why the icon doesn't show in /Debug?
At runtime it's ok,but
Bookmarks