Click here to Skip to main content
13,000,135 members (56,076 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hello everybody.
In chapter 02 of "C++ GUI Programming with Qt4, 2nd edition" is an example which when I implemented, compiled and run it, give me an error about segmentation fault.
I uploaded all the codes at :[^] (about 22 Kb)
Thanks a lot of everybody who would help me ...
Posted 5-Jul-13 14:18pm
smss IR407
The_Inventor 6-Jul-13 4:42am
Often these books will have 'errors' so that you will have to do some coding=work. Read the material again.
smss IR 6-Jul-13 9:56am
I read it for tertiary again! but doesn't have any inconsistency with the written codes by me.
Matthew Faithfull 6-Jul-13 5:22am
Use the debugger to determine where the segmentation fault is happening, which file, which function, which line if you can. If that doesn't allow you to fix the problem it will help someone to help you.
smss IR 6-Jul-13 9:56am
Thanks man.
Richard MacCutchan 6-Jul-13 6:32am
If you aspire to be a developer then you need to learn not to give up so easily. Make an effort to at least find the line of code that is failing, so you can provide some useful detail about your problem. And finally, understand that no one is going to download this code and debug it for you.
smss IR 6-Jul-13 9:56am
Thanks Richard.
smss IR 6-Jul-13 10:18am
I debugged it, and I understand where is the code which having the error.
That error is in : "//layout()->setSizeConstraint(QLayout::SetFixedSize);" which when I commented it, program run as successfully.
What is the problem?
Thanks everybody.
pasztorpisti 6-Jul-13 17:01pm
It can crash either in the layout() call, in the setSizeContstrain() call, or simply because the pointer returned by layout() is NULL. I would start by logging/debugging out the pointer returned by layout() because doing so you would be able to decide which of the 3 cases can cause the problem.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

use the debugger to find the exact crash location. And than search for working sample code of that piece.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 9 Jul 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100