Results 1 to 4 of 4

Thread: SetSizeConstraint gives Segmentation fault.

  1. #1
    Join Date
    Oct 2007
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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.

    Qt Code:
    1. SortDialog::SortDialog(QWidget *parent)
    2. : QDialog(parent)
    3. {
    4. setupUi(this);
    5.  
    6. secondaryGroupBox->hide();
    7. tertiaryGroupBox->hide();
    8. layout()->setSizeConstraint(QLayout::SetFixedSize);
    9. setColoumnRange('A', 'Z');
    10. }
    To copy to clipboard, switch view to plain text mode 
    When I add the line
    Qt Code:
    1. layout()->setSizeConstraint(QLayout::SetFixedSize);
    To copy to clipboard, switch view to plain text mode 
    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SetSizeConstraint gives Segmentation fault.

    Do you have a top-level layout on that dialog?

  3. #3
    Join Date
    Oct 2007
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default 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?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: SetSizeConstraint gives Segmentation fault.

    Quote Originally Posted by indy View Post
    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.

Similar Threads

  1. QTreeWidgetItem - segmentation fault
    By szczav in forum Qt Programming
    Replies: 1
    Last Post: 4th June 2007, 22:54
  2. Process aborted. Segmentation fault
    By Pragya in forum Qt Programming
    Replies: 3
    Last Post: 30th May 2007, 08:12
  3. Segmentation fault running any QT4 executables
    By jellis in forum Installation and Deployment
    Replies: 7
    Last Post: 19th May 2007, 16:35
  4. Icons missing => segmentation fault
    By antonio.r.tome in forum Qt Programming
    Replies: 4
    Last Post: 8th March 2006, 16:30
  5. [qmake_image_collection.cpp] Segmentation fault
    By CrazyLegz in forum KDE Forum
    Replies: 1
    Last Post: 4th February 2006, 11:43

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.