Results 1 to 4 of 4

Thread: Crashing problem while checking for QCheckBox is CHECKED/UNCHECKED

  1. #1
    Join Date
    Jun 2011
    Posts
    26
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Crashing problem while checking for QCheckBox is CHECKED/UNCHECKED

    hi,
    Here is my code for checking wheater the QCheckBox is checked or not.
    I don't want to use SIGNALS & SLOTS.Give me some solution which has no SIGNALS & SLOT coz using SIGNALS & SLOTS its too lengthy for my code as i have to check 25 checkBoxes.So please keep it short n sweet..

    QCheckBox *floor1 = new QCheckBox("Floor 1",this);
    floor1->setCheckable(1);

    if(floor1->isChecked()) //the code is crashing at this line
    {
    if(this->door11->isChecked())
    line.append("Door 11");
    }

    Also i tried with below code but same problem.

    if(floor1->checkState()==Qt::Checked) //the code is crashing at this line
    {
    if(this->door11->isChecked())
    line.append("Door 11");
    }

    Please help me to overcome this issue ASAP...

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Crashing problem while checking for QCheckBox is CHECKED/UNCHECKED

    The most likely problem is that floor1 is either NULL or pointing at a no-longer-valid location. What is the value of floor1 at the line it crashes?

    I can only assume that the scope in which:
    Qt Code:
    1. QCheckBox *floor1 = new QCheckBox("Floor 1",this);
    2. floor1->setCheckable(1); // unnecessary, check boxes are checkable by default
    To copy to clipboard, switch view to plain text mode 
    occurs, and the remainder occurs are not the same or the crash would occur at line 2.
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

  3. #3
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Crashing problem while checking for QCheckBox is CHECKED/UNCHECKED

    Qt Code:
    1. QCheckBox *floor1 = new QCheckBox("Floor 1",this);
    2. floor1->setCheckable(1);
    3.  
    4. //make sure floor1 is properly allocated, are you sure the above new statement is called before this?
    5. if(floor1->isChecked()) //the code is crashing at this line
    6. {
    7. if(this->door11->isChecked())
    8. line.append("Door 11");
    9. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jun 2011
    Posts
    26
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Crashing problem while checking for QCheckBox is CHECKED/UNCHECKED

    Thank you..
    From next time i will follow code posting guidelines Chris..Thanks for the reply..

    Thank you.. i got it done..

Similar Threads

  1. Crashing without debug mode- No crashing with gdb debugger
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 1
    Last Post: 7th February 2011, 11:27
  2. Replies: 1
    Last Post: 29th November 2010, 15:47
  3. Which QCheckBox has been checked?
    By alexandernst in forum Newbie
    Replies: 2
    Last Post: 14th September 2009, 10:09
  4. Replies: 8
    Last Post: 2nd February 2009, 12:25
  5. Which QCheckBox is checked?
    By Craig.Smith in forum Qt Programming
    Replies: 2
    Last Post: 9th November 2007, 14:52

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.