PDA

View Full Version : Yet another bunch of doubts!



Nishant
23rd December 2009, 14:24
1.use of qapplication(argc,argv)?==>why we pass the command line arguments to app object?
2.why a heap is needed to delete automatically the child objects of a widget ,when it is deleted,and whyy it is not possible on a stack
ie why we use new operator???
3. clear difference between callback functions,event listeners and slot-signal concept?

high_flyer
23rd December 2009, 15:45
Look, this is a Qt forum, not programming basics forum.
All your questions are covered in the basics of programming, and basics of C programming.
Get a good book on the subject, or find many explanations about it on Google.
You are welcome to ask Qt related questions.

franz
23rd December 2009, 15:49
1.use of qapplication(argc,argv)?==>why we pass the command line arguments to app object?
Because QApplication can take some command line arguments, influencing the rendering of your program. Read this (http://doc.trolltech.com/4.6/qapplication.html#QApplication).


2.why a heap is needed to delete automatically the child objects of a widget ,when it is deleted,and whyy it is not possible on a stack
ie why we use new operator???
Actually you're looking at it from the wrong perspective. If you would be allocating everything on stack, you wouldn't have any reason to create an object structure. It is necessary because allocation on heap requires some sort of data management to prevent memory leaks. Allocating on the heap is much more convenient because you don't have to worry about your QObject going out of scope. A minor worry should be that you might loose the pointer to your QObject, but if you've written your program properly the object should be deleted when it shuts down.



3. clear difference between callback functions,event listeners and slot-signal concept?Read this (http://doc.trolltech.com/latest/signalsandslots.html) and this (http://doc.trolltech.com/4.6/eventsandfilters.html). Maybe it clears something up for you.