Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ QT GUI Errors
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 : http://ubuntuone.com/1BwwCaFw9801KfL39I7cA6[^] (about 22 Kb)
Thanks a lot of everybody who would help me ...
Posted 5-Jul-13 15:18pm
smss IR399
Comments
The_Inventor at 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 at 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 at 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 at 6-Jul-13 9:56am
   
Thanks man.
Richard MacCutchan at 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 at 6-Jul-13 9:56am
   
Thanks Richard.
smss IR at 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 at 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
good
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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 273
1 Maciej Los 255
2 Aajmot Sk 234
3 Richard MacCutchan 200
4 Marcin Kozub 195
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,127
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 9 Jul 2013
Copyright © CodeProject, 1999-2014
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