Results 1 to 3 of 3

Thread: setSizeConstraint and segmentation fault

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Piekary Slaskie, Poland
    Posts
    6
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default setSizeConstraint and segmentation fault

    I have a example source code from C++ GUI Programming with Qt 4 book. There is in main class construct:
    Qt Code:
    1. SortDialog::SortDialog(QWidget *parent)
    2. : QDialog(parent){
    3.  
    4. setupUi(this);
    5. secondaryGroupBox->hide();
    6. tertiaryGroupBox->hide();
    7. //layout()->setSizeConstraint(QLayout::SetFixedSize);
    8. setColumnRange('A', 'Z');
    9. }
    To copy to clipboard, switch view to plain text mode 
    When I compile this in this form, everything works ok. But if I remove this comment, after compile when I want to run this app, I have segmentation fault.

    There is no diffrent if I replace SetFixedSize for e.g. SetMaximumSize or someone else from enum SizeConstraint from QLayout class.

    Why isn't it work?
    Qt4.3.3

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setSizeConstraint and segmentation fault

    That's because you don't have a main(top level) layout set in your dialog.
    What you have to do is to open the ui file in designer, right click the form and choose a layout for it(whatever you need). Next save the ui, rebuild and it will work.

  3. The following user says thank you to marcel for this useful post:

    lszk (3rd May 2008)

  4. #3
    Join Date
    Feb 2006
    Location
    Piekary Slaskie, Poland
    Posts
    6
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: setSizeConstraint and segmentation fault

    Thanks. Now is ok.

Similar Threads

  1. Replies: 3
    Last Post: 11th October 2007, 23:47

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
  •  
Qt is a trademark of The Qt Company.