您的位置:首页 > 产品设计 > UI/UE

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:

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()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: