PDA

View Full Version : How to add QButtongroup to Layout?



pospiech
27th April 2008, 13:03
Originally I had two QRadioButtons withing Layout which in the end were no exclusive. Therefore I try to add them to a QButtonGroup. Unfortinately I could find no example or these were for Qt3.

If there is a possibility to do all this mainly within the designer that would be great, but I dont know how. So in case please let me know.

This is what I coded so far. But in the end it fails because the QButtonGroup is no widget and I have no idea to add it to the layout.



radioButtonNoFFT = new QRadioButton(this);
radioButtonNoFFT->setObjectName(QString::fromUtf8("radioButtonNoFFT"));
radioButtonNoFFT->setChecked(true);

radioButtonFFT = new QRadioButton(this);
radioButtonFFT->setObjectName(QString::fromUtf8("radioButtonFFT"));

buttongroup = new QButtonGroup(this);
buttongroup->addButton(radioButtonNoFFT);
buttongroup->addButton(radioButtonFFT);

gridLayoutButtonGroup = new QGridLayout(this);
gridLayoutButtonGroup->setObjectName(QString::fromUtf8("gridLayoutButtonGroup"));
gridLayoutButtonGroup->addWidget(buttongroup);

gridLayout->addLayout(gridLayoutButtonGroup, 1, 0, 1, 1);

pospiech
27th April 2008, 13:22
In the end I now found out that this is everthiny I need to do:


setupUi(this);

buttongroup = new QButtonGroup(this);
buttongroup->addButton(radioButtonNoFFT);
buttongroup->addButton(radioButtonFFT);

finding this out however caused me about 2 hours of trying to find some code example and implement whatever I could find...