[Qt-interest] QRadioButton setDown(true) initialise problem.
phil prentice
philp.cheer at talktalk.net
Thu Jan 7 16:04:15 CET 2010
Hi
I have an application where I need to initialise a radiobuttons state at
startup. If I create the button and then set down to true, when I go and
select other radiobuttons using the mouse (buttons have same parent)the radio
button that I originally pressed down via setDown() will remain down until I
use the mouse to select it then all the buttons work fine(exclusively) as
expected.
Heres a bit of code to demonstrate (although to be honest this seems to have
even more bizaire consequences, but thats another problem).
#include <QApplication>
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication app(argc,argv);
QWidget *top = new QWidget();
QRadioButton *q1 = new QRadioButton("button1",top);
QRadioButton *q2 = new QRadioButton("button2",top);
q1->setDown(true);
q2->setDown(true);
q1->move(5,10);
q2->move(5,40);
top->show();
return app.exec();
}
I get some strange results when I run the above which I dont understand.
When I first see the displayed widget I see both radio buttons down..which is
wrong. However if I simply move my mouse the first button is changed to being
up (which is what I would have expected to see when it was first
displayed???).
Anyway I now move on to my main problem which is that when I select button1
with the mouse button 2 remains down. Its not until I select button2 with
the mouse that both buttins start behaving as they should do.
I know the above code is a bit basic, but I just wanted to demonstarte my
problem(s).
I'm using QT 4.2.1 which I appreciate is a bit out of date now, but I'm sure
its my understanding that is at fault here.
What am I doing wrong?
Thanks for your help.
More information about the Qt-interest-old
mailing list