PDA

View Full Version : Program quits unexpectedly



MCFormax
7th November 2011, 02:01
I have experience programming C++ and building GUIs with Windows Forms (Visual C++ Express). I decided to try Qt4 and I am using as tutorial the book "C++ GUI Programming with Qt 4 (2nd Edition)
Jasmin Blanchette , Mark Summerfield." I did the examples in chapters 1 and 2 and they work fine excepting the example "Sort" about "Shape-Changing Dialogs".
It compiles but when I run it I get an error window stating "Sort quit unexpectedly. Click Reopen to to open the application again. Click Report to see more detailed information and send a report to Apple"

Following the program execution with the debugger I found that the statement that fails is in constructor:
SortDialog::SortDialog(QWidget *parent) : QDialog(parent)
{
setupUi(this);
secondaryGroupBox->hide();
tertiaryGroupBox->hide();
layout()->setSizeConstraint(QLayout::SetFixedSize);

setColumnRange('A', 'Z');
}

line "layout()->setSizeConstraint(QLayout::SetFixedSize);"

When I ask the debugger to "step into" this line a get another message stating,
"The inferior stopped because it received a signal from the Operating System
Signal name: EXC_BAD_ACCESS
Signal meaning: Could not access memory"

I am building the program with Qt Creator 2.3.1 based on Qt 4.7.6 (64 bit).
My computer is a MacBookPro (latest edition) with OS X Lion. It has 4 MB ram. I have already tried the following without success:
Click "Reopen" in the first error message dialog box
Close all the applications excepting "Finder" where the application file is. This is to have as much memory as possible available to the program.
Rebooting the computer.
Erasing all the program code and starting from scratch.
Commenting out the offending line (statement). In this case the program runs, loosing some functionality.

Any ideas about solving this problems?
Thank you
MCFormax, 11/05/11

Santosh Reddy
7th November 2011, 03:19
a quick observation

Make sure layout() is returning a valid layout pointer, the ui (from) might not be adding a layout to the dialog, I bet this should be the problem.

MCFormax
9th November 2011, 03:31
That was it. I associated a layout manager to the main program window (the window containing all the widgets) and now it works fine

Thank you,
MCFormax