Results 1 to 11 of 11

Thread: QCheckBox::isChecked() property is not working...

  1. #1
    Join Date
    Dec 2006
    Location
    Bangalore, India
    Posts
    38
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Angry QCheckBox::isChecked() property is not working...

    Hi,

    QCheckBox's isChecked() property is not working.
    When I tried to check the corresponding QCheckBox object isChecked() by using the following code.
    Qt Code:
    1. if (checkbox[i]->isChecked() == true)
    2. { }
    To copy to clipboard, switch view to plain text mode 

    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.
    WINNERS DON`T D DIFFERENT THINGS THEY D THINGS differently.

  2. #2
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: QCheckBox::isChecked() property is not working...

    Hi,
    maybe try cb->checkState () == Qt::Checked

  3. #3
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QCheckBox::isChecked() property is not working...

    or maybe use

    QCheckBox::setCheckState ( Qt::CheckState state )

    (i think its more proper)

  4. #4
    Join Date
    Dec 2006
    Location
    Bangalore, India
    Posts
    38
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QCheckBox::isChecked() property is not working...

    Thanks Folks,
    I tried these ways but nothing is working fine. Any more help..????
    WINNERS DON`T D DIFFERENT THINGS THEY D THINGS differently.

  5. #5
    Join Date
    Dec 2006
    Location
    Bangalore, India
    Posts
    38
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QCheckBox::isChecked() property is not working...

    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...
    WINNERS DON`T D DIFFERENT THINGS THEY D THINGS differently.

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QCheckBox::isChecked() property is not working...

    Erm?
    Qt Code:
    1. // main.cpp
    2. #include <QtGui>
    3.  
    4. int main(int argc, char* argv[])
    5. {
    6. QApplication app(argc, argv);
    7. QCheckBox checkBox;
    8. qDebug() << checkBox.isChecked(); // "false"
    9. checkBox.setChecked(true);
    10. qDebug() << checkBox.isChecked(); // "true"
    11. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  7. #7
    Join Date
    Dec 2006
    Location
    Bangalore, India
    Posts
    38
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Re: QCheckBox::isChecked() property is not working...

    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. 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.
    Attached Files Attached Files
    WINNERS DON`T D DIFFERENT THINGS THEY D THINGS differently.

  8. #8
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QCheckBox::isChecked() property is not working...

    you forgot to attach scrollcheck.h, frameScroll.h

  9. #9
    Join Date
    Dec 2006
    Location
    Bangalore, India
    Posts
    38
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QCheckBox::isChecked() property is not working...

    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.
    WINNERS DON`T D DIFFERENT THINGS THEY D THINGS differently.

  10. #10
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QCheckBox::isChecked() property is not working...

    look at code and find the bug
    Qt Code:
    1. OptionDlg::OptionDlg(QWidget *parent, Qt::WFlags flags) : QDialog(parent, flags)
    2. {
    3. QVBoxLayout *mainLayout = new QVBoxLayout;
    4. QHBoxLayout *hBtLayout = new QHBoxLayout;
    5. QHBoxLayout *layout = new QHBoxLayout;
    6.  
    7. frmScroll = new FrameScroll(this);
    8. frmScroll->setFrameStyle( QFrame::Box | QFrame::Raised );
    9. frmScroll->setMinimumSize( 20, 20 );
    10. layout->addWidget(frmScroll);
    11.  
    12. mainLayout->addLayout(layout);
    13.  
    14. submitBt = new QPushButton(tr("&Ok"));
    15. cancelBt = new QPushButton(tr("&Cancel"));
    16.  
    17. connect(submitBt, SIGNAL(clicked()), this, SLOT(processUserInput()));
    18. connect(cancelBt, SIGNAL(clicked()), this, SLOT(close()));
    19. hBtLayout->addSpacing(200);
    20. hBtLayout->addWidget(submitBt);
    21. hBtLayout->addWidget(cancelBt);
    22. mainLayout->addLayout(hBtLayout);
    23. setLayout(mainLayout);
    24. setWindowTitle(tr("Basic Layouts"));
    25. };
    26.  
    27. OptionDlg::~OptionDlg()
    28. { };
    29.  
    30. void OptionDlg::processUserInput() {
    31. //FrameScroll *frmScroll = new FrameScroll(this);//<---- you create a new widget and get data from it
    32. //QString sr = frmScroll->cbx->text();
    33. //bool cbool = true;
    34. qDebug() << (frmScroll->cbx->isChecked());
    35. //this->close();
    36. }
    To copy to clipboard, switch view to plain text mode 
    PS. for feature,please post code in archive.

  11. The following user says thank you to spirit for this useful post:

    Cutey (18th August 2008)

  12. #11
    Join Date
    Dec 2006
    Location
    Bangalore, India
    Posts
    38
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QCheckBox::isChecked() property is not working...

    Thanks for your timely help buddy and Thanks for pointing out my blunder..
    WINNERS DON`T D DIFFERENT THINGS THEY D THINGS differently.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.