Qt interview questions
2013-04-13 14:55
281 查看
1.DescribeSignals&Slots.
A:SignalsansSlotsareusedforcommunicationbetweenobjects.Itshallreplacegenerallywayofcallbackstoavoidtheflawsfromcallbacks.
AnyclassdeprivedfromQObjectcanhaveitsownsignalsandslots.
2.HowSignals&Slotswork?WhatisMetaObjectsystem?
3.Objectandsignals&slots.
4.QObjectrelated.Whatclassdoineedtoinheritifiwanttohavesignals&slots?ORWhyisQObjectaspecialclass?
5.WhatisO_OBJECTmacro?Doyouknowwhatitexpandsinto?
6.Whatareslots?
7.Canicallaslotnormally?
A:yes,ofcourse.Youcandefineslotasnormalmemberfunctions.Youcanuseidentifierpublic,protecedandprivatetosetthescopeofeachslotsfunctions.
8.Canslotsbevirtual?
A:yes,itcanbedefinedasvirtualandcanbeinheritedbychildclass.
Itevencanbepureviruallike:
Justlikeregularc++purevirtualmethods.ThecodegeneratedbyMOCdoescallthepurevirtualslots,butthat'soksincethebaseclasscan'tbeinstantiatedanyway...
Again,justlikeregularc++purevirtualmethods,theclasscannotbeinstantiateduntilthemethodsaregivenanimplementation.
Onething:inthesubclass,youactualllydon'tneedtomarktheoverridenmethodsasslots.One,they'realreadyimplementedasslotsinthebaseclass.Two,you'rejustcreatingmoreworkfortheMOCandcompilersinceyou'readdinga(tiny)bitmorecode.Trivial,butwhatever.
9.CanicallaSignalnormally?
A:no,youcannot.onlycanbeemit.(?)
10.Givethesyntax/prototypeofconnect().
A: connect(obj1,SIGNAL(sigFunc(arg...)),obj2,SLOT(slotFunc(arg...)));
11.Caniconnecttwosignals?how?
A:Yes.thingsworklikepassthiseventsfromoneobjecttoanotherobject.
---connect(obj1,SIGNAL(sigFun()),obj2,SIGNAL(sigOtherFunc()));
12.Whatistheorderofcallingofslotsconnectedtothesamesignal?
A:Ifitisinsingleprocess(thread)mode,itshallbecalledinsequenceofthedefinitionofconnect.
IfiitisinMultiplethreadsmode,needtocheck
13.WhatarethecontainerclassesyouhaveusedinQt?
A:QVector,QMap,QList,Q
14.WhatisthedifferencebetweenQList,QLinkedList,QVectoretc.
15.Whatisimplicitsharing?HowQtusesit.
16.Question:Whatisthedifferencebetweenclose()andhide()inQt?
Answer:
1)Acloseeventissentbeforethewidgetclosesandcanbeignored,in
thiscasetheWindowwon'tclose.Ahideeventissentwhenthewidget
hasbeenhidden.
2)close()deletestheclosedwidgetiftheWDestructiveCloseflaghas
beensetduringconstructionofthewidget.Ifthatflaghasnotbeen
setyouhavetodeletethewidgetyourself.Whenyoudeletetheformthe
widgetsontheformwillbedeletedaswell.
Note:Awidgetreceivesspontaneousshowandhideeventswhenits
mappingstatusischangedbythewindowsystem,e.g.aspontaneoushide
eventwhentheuserminimizesthewindow,andaspontaneousshowevent
whenthewindowisrestoredagain.Afterreceivingaspontaneoushide
event,awidgetisstillconsideredvisibleinthesenseof
isVisible().
(1)WhyQtdoesnotusetemplatesforsignals/slotimplementation?
(2)ExplainmemorymanagementinQt.
Q.WhatdoesSIGNAL()andSLOT()macroexpandto?
Q.DoesQthasGarbagecollectionsystem?
Q.whatis"emit","slots","signals"?(aretheymacro,keywordorfunction?)
Q.Haveyoumadeanycustomwidgetyourself?
Q.WhatclassesdoesQtprovidestohandleXML?
Q.DifferencebetweenDom,SAX,Readers?
Q.Howdoyouusethreadclasses?
Q.WhatisQMutexandhowdoyouuseit?
Q.ExplainModelViewframework.Andmentiononesituationwhereyouusedit.
Q.Howdoyoucommunicatebetweenthreads?
Q.WhatisQApplication?
Q.IficreatetwoobjectsofQApplicationwhatwillhappen?Whyshouldn'tiusetwo?
Q.WhatisQ_SLOTS?whyitisneeded?whatstheproblemin"slots"?
1.whereexactlywehavetousethisfollowingunicodeclasses
QString(),
QByteArray(),
QTextStream(),
QTextCodec()
A:SignalsansSlotsareusedforcommunicationbetweenobjects.Itshallreplacegenerallywayofcallbackstoavoidtheflawsfromcallbacks.
AnyclassdeprivedfromQObjectcanhaveitsownsignalsandslots.
2.HowSignals&Slotswork?WhatisMetaObjectsystem?
3.Objectandsignals&slots.
4.QObjectrelated.Whatclassdoineedtoinheritifiwanttohavesignals&slots?ORWhyisQObjectaspecialclass?
5.WhatisO_OBJECTmacro?Doyouknowwhatitexpandsinto?
6.Whatareslots?
7.Canicallaslotnormally?
A:yes,ofcourse.Youcandefineslotasnormalmemberfunctions.Youcanuseidentifierpublic,protecedandprivatetosetthescopeofeachslotsfunctions.
8.Canslotsbevirtual?
A:yes,itcanbedefinedasvirtualandcanbeinheritedbychildclass.
Itevencanbepureviruallike:
classBaseConfigurationPage:publicQWidget{ //Someconstructorandothermethods,irrelevanthere. publicslots: virtualvoidloadSettings()=0; virtualvoidsaveSettings()=0; }; classGeneralConfigurationPage:publicBaseConfigurationPage{ //Someconstructorandothermethods,irrelevanthere. //publicslots:donotneedthishereanymore voidloadSettings(); voidsaveSettings(); };
Justlikeregularc++purevirtualmethods.ThecodegeneratedbyMOCdoescallthepurevirtualslots,butthat'soksincethebaseclasscan'tbeinstantiatedanyway...
Again,justlikeregularc++purevirtualmethods,theclasscannotbeinstantiateduntilthemethodsaregivenanimplementation.
Onething:inthesubclass,youactualllydon'tneedtomarktheoverridenmethodsasslots.One,they'realreadyimplementedasslotsinthebaseclass.Two,you'rejustcreatingmoreworkfortheMOCandcompilersinceyou'readdinga(tiny)bitmorecode.Trivial,butwhatever.
9.CanicallaSignalnormally?
A:no,youcannot.onlycanbeemit.(?)
10.Givethesyntax/prototypeofconnect().
A: connect(obj1,SIGNAL(sigFunc(arg...)),obj2,SLOT(slotFunc(arg...)));
11.Caniconnecttwosignals?how?
A:Yes.thingsworklikepassthiseventsfromoneobjecttoanotherobject.
---connect(obj1,SIGNAL(sigFun()),obj2,SIGNAL(sigOtherFunc()));
12.Whatistheorderofcallingofslotsconnectedtothesamesignal?
A:Ifitisinsingleprocess(thread)mode,itshallbecalledinsequenceofthedefinitionofconnect.
IfiitisinMultiplethreadsmode,needtocheck
13.WhatarethecontainerclassesyouhaveusedinQt?
A:QVector,QMap,QList,Q
14.WhatisthedifferencebetweenQList,QLinkedList,QVectoretc.
15.Whatisimplicitsharing?HowQtusesit.
16.Question:Whatisthedifferencebetweenclose()andhide()inQt?
Answer:
1)Acloseeventissentbeforethewidgetclosesandcanbeignored,in
thiscasetheWindowwon'tclose.Ahideeventissentwhenthewidget
hasbeenhidden.
2)close()deletestheclosedwidgetiftheWDestructiveCloseflaghas
beensetduringconstructionofthewidget.Ifthatflaghasnotbeen
setyouhavetodeletethewidgetyourself.Whenyoudeletetheformthe
widgetsontheformwillbedeletedaswell.
Note:Awidgetreceivesspontaneousshowandhideeventswhenits
mappingstatusischangedbythewindowsystem,e.g.aspontaneoushide
eventwhentheuserminimizesthewindow,andaspontaneousshowevent
whenthewindowisrestoredagain.Afterreceivingaspontaneoushide
event,awidgetisstillconsideredvisibleinthesenseof
isVisible().
(1)WhyQtdoesnotusetemplatesforsignals/slotimplementation?
(2)ExplainmemorymanagementinQt.
Q.WhatdoesSIGNAL()andSLOT()macroexpandto?
Q.DoesQthasGarbagecollectionsystem?
Q.whatis"emit","slots","signals"?(aretheymacro,keywordorfunction?)
Q.Haveyoumadeanycustomwidgetyourself?
Q.WhatclassesdoesQtprovidestohandleXML?
Q.DifferencebetweenDom,SAX,Readers?
Q.Howdoyouusethreadclasses?
Q.WhatisQMutexandhowdoyouuseit?
Q.ExplainModelViewframework.Andmentiononesituationwhereyouusedit.
Q.Howdoyoucommunicatebetweenthreads?
Q.WhatisQApplication?
Q.IficreatetwoobjectsofQApplicationwhatwillhappen?Whyshouldn'tiusetwo?
Q.WhatisQ_SLOTS?whyitisneeded?whatstheproblemin"slots"?
1.whereexactlywehavetousethisfollowingunicodeclasses
QString(),
QByteArray(),
QTextStream(),
QTextCodec()
相关文章推荐
- Oracle DBA Interview Questions
- 面试时最经常被问到的问题(Frenquently asked interview questions)之Microsoft and other companies篇
- 面试时最经常被问到的问题(Frenquently asked interview questions)(II)
- C# Interview Questions
- Popular HashMap and ConcurrentHashMap Interview Questions
- JAVA INTERVIEW QUESTIONS
- What Great .NET Developers Ought To Know (More .NET Interview Questions)
- Java Interview Questions/Java面试题
- What Great .NET Developers Ought To Know (More .NET Interview Questions)
- ASP.NET Interview Questions
- Java/J2EE Job Interview Companion - 400+ Questions & Answers
- Struts, hibernate and spring interview questions
- Commonly asked JavaScript interview questions
- What Great .NET Developers Ought To Know (More .NET Interview Questions)
- LeetCode Interview Questions Online Judge
- Front-end Job Interview Questions
- How to prepare system design questions in a tech interview?
- 115 Java Interview Questions and Answers
- node-interview-questions
- [QTP] Interview questions on Qui…