PDA

View Full Version : QCheckBox::isChecked() property is not working...



Cutey
9th August 2008, 08:44
Hi,

QCheckBox's isChecked() property is not working.
When I tried to check the corresponding QCheckBox object isChecked() by using the following code.

if (checkbox[i]->isChecked() == true)
{ }

The strange is that rest of all property is working fine except the isChecked(). FYI, By default this is returning "false" value.

Please Please could any one give me a "workaround" for this problem.

janus
9th August 2008, 12:56
Hi,
maybe try cb->checkState () == Qt::Checked

triperzonak
9th August 2008, 13:20
or maybe use

QCheckBox::setCheckState ( Qt::CheckState state ) (http://doc.trolltech.com/4.4/qcheckbox.html#setCheckState)

(i think its more proper)

Cutey
11th August 2008, 07:11
Thanks Folks,
I tried these ways but nothing is working fine. Any more help..????:confused:

Cutey
12th August 2008, 10:01
Hello,

Still I'm looking for solution...!!!!!

Even QRadioButton's "isChecked()" property also not working by default these are all returning "false" values.
I don't know what the blunder I have done.???

Please help me folks... :crying:

jpn
12th August 2008, 18:04
Erm?


// main.cpp
#include <QtGui>

int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QCheckBox checkBox;
qDebug() << checkBox.isChecked(); // "false"
checkBox.setChecked(true);
qDebug() << checkBox.isChecked(); // "true"
}

Cutey
13th August 2008, 08:55
Thanks a lot folks... At last I got my exact problem.

My problem is that QCheckBox/QRadioButton::isChecked() property in QScrollArea is returning FALSE by default .

It's strange for me:crying:. Could any one help me in this regard...
Please find the attachment where you could get my project's prototype. In that code checkout the "void OptionDlg:: processUserInput()" method.

Please Please Help me folkssssssssssssss.

spirit
13th August 2008, 09:31
you forgot to attach scrollcheck.h, frameScroll.h

Cutey
13th August 2008, 10:27
My dear,

Please download the file and look into the files. There you could find all necessary files.
I did not attach as a separate files because forum supports only 5 files max to attach.

spirit
13th August 2008, 11:08
look at code and find the bug


OptionDlg::OptionDlg(QWidget *parent, Qt::WFlags flags) : QDialog(parent, flags)
{
QVBoxLayout *mainLayout = new QVBoxLayout;
QHBoxLayout *hBtLayout = new QHBoxLayout;
QHBoxLayout *layout = new QHBoxLayout;

frmScroll = new FrameScroll(this);
frmScroll->setFrameStyle( QFrame::Box | QFrame::Raised );
frmScroll->setMinimumSize( 20, 20 );
layout->addWidget(frmScroll);

mainLayout->addLayout(layout);

submitBt = new QPushButton(tr("&Ok"));
cancelBt = new QPushButton(tr("&Cancel"));

connect(submitBt, SIGNAL(clicked()), this, SLOT(processUserInput()));
connect(cancelBt, SIGNAL(clicked()), this, SLOT(close()));
hBtLayout->addSpacing(200);
hBtLayout->addWidget(submitBt);
hBtLayout->addWidget(cancelBt);
mainLayout->addLayout(hBtLayout);
setLayout(mainLayout);
setWindowTitle(tr("Basic Layouts"));
};

OptionDlg::~OptionDlg()
{ };

void OptionDlg::processUserInput() {
//FrameScroll *frmScroll = new FrameScroll(this);//<---- you create a new widget and get data from it
//QString sr = frmScroll->cbx->text();
//bool cbool = true;
qDebug() << (frmScroll->cbx->isChecked());
//this->close();
}

PS. for feature,please post code in archive.

Cutey
18th August 2008, 08:14
Thanks for your timely help buddy and Thanks for pointing out my blunder..