SetSizeConstraint gives Segmentation fault.
I am reading the book "C++ GUI programming with QT4" and I have a problem with the example of the Shape-Changing dialogs in chapter 2. I followed the tutorial by designing the GUI with designer and building the project in Eclipse. Everything compiles fine. The problem is with the constructor of the dialog box.
Code:
SortDialog
::SortDialog(QWidget *parent
){
setupUi(this);
secondaryGroupBox->hide();
tertiaryGroupBox->hide();
layout
()->setSizeConstraint
(QLayout::SetFixedSize);
setColoumnRange('A', 'Z');
}
When I add the line
Code:
layout
()->setSizeConstraint
(QLayout::SetFixedSize);
the project compiles but when I try to run the executable I get Segmentation fault. Without that line the program runs ok but of course the dialog doesn't resize.
I am using Linux with KDE. Can anyone explain what is wrong please?
Re: SetSizeConstraint gives Segmentation fault.
Do you have a top-level layout on that dialog?
Re: SetSizeConstraint gives Segmentation fault.
Thank you, that was it. I did a Layout->Layout in a grid and then it ran fine. The strange thing is that I could not reproduce the same layout using designer. I did it with the Qt plugin for Eclipse. I hope with experience will avoid such mistakes in the future but is there any way to ensure that there is always a top level layout?
Re: SetSizeConstraint gives Segmentation fault.
Quote:
Originally Posted by
indy
is there any way to ensure that there is always a top level layout?
You don't have to use layouts, so Qt Designer doesn't know whether it's OK or not if you did't add the top-level layout. Although it warns you about a missing top-level layout when you try to save an .ui file with spacers.
I simply test all m .ui files before saving them.