You have been watching... T he i nno You have You have You w a ne a co ant v ato mma r 's h w C+ ndlin e + "c e ad o mp k c i u Q t Q t a k o A Q u i c k Lo D a y Tim B ub impo b le s rt Q tQui .qm ck 1 import QtQuick 1.1 Rectang le { id: s lide width : viewe r.width heigh t: view er.heig ht color : '#fff fff' smoot h: true focus : true state : "NORM AL" prope rty rea l heade rHeight : heigh t*0.1 prope rty rea l foote rHeight : heade rHeight eight-f ooterHe ight prope rty rea l bodyH eight: height- headerH prope rty int galler yIndex: -1 "" prope rty str ing tit letext: Slide Header { tit letext: parent .titlet ext } Slide Footer {} Bubbl es { vis ible: ( parent. state== "NORMAL ") } Slide Shadow { vis ible: ( parent. state== "GALLER Y") z: -1 } Slide Gallery Animati on { t scope parent qualifi er, ani mations live i n paren run ning: ( state== "GALLER Y") // NB no } Mouse Area { anc hors.fi ll: par ent ghtButt on acc eptedBu ttons: Qt.Left Button | Qt.Ri onC licked: { ton ? 1 : -1); v iewer.m ove(mou se.butt on==Qt. LeftBut } } Keys. onPress ed: { ove(1); event.a ccepted =true;} if (event. key==Qt .Key_Ri ght) {v iewer.m er.move (-1);ev ent.acc epted=t rue;} els e if (e vent.ke y==Qt.K ey_Left ) {view p on e nt s in Q ML M M Q t o r b l e d an 1. uick t QtQ impor Mbrot 1.0 t impor B ":x} ); e c r u o Ls 1 pone + com nts i n QML " { Slide etext: "C+ l ton tit htBut t.Rig ot a { ton|Q r e t b r u m A B e t : s f e.y); Mou chors.fill ns: Qt.Le ,mous { o n ton) el(mouse.x t u a ceptedButt ed: { B t k Pix c .Lef a DoubleClic utton==Qt positionOf b n . o if (mouse. tre=mbrot n mbrot.ce ius*=0.5; d mbrot.ra gy)); } else { =2.0; x,dra dius* (drag mbrot.ra l e x i nOfP } true; sitio pted= ot.po mouse.acce ),mbr y . e s u x,mo : { { ouse. anged y>=0) xel(m } PositionCh 0 && drag ; nOfPi = o n e > i o u x t r g i t e= dra pos wnsiz if ( brot. mbrot.do eCentre(m v e;} mbrot.mo use.y =fals gy=mo nsize } x;dra t.dow . o e r s b u m o ; x=m =-1 drag dragy x=-1; {drag 1 } Released: dragx: 1,1)] l n 1 (0,0, o operty rea dragy: .rgba t Q l , r a ) p e 0 operty r 0,1, r ba(0, p Qt.rg 1,1), , 0 , } 0 rgba( ht ),Qt. rHeig 0,1,0 ot { heade terHeight t.rgba(0, t . n t Mbr : mbrot e n r e a : p foo d *par 1),Q i chors.fill rgin: 1.1 .1*parent. (0,0,0.5, a a n 1 a chors.topM mMargin: ,0),Qt.rgb o n 0 a chors.bott rgba(0,0, . n a lors: [ Qt o c } {} anel trolP otCon Mbr } Qt Bullet.qml e c r u o s ic s ions ' m t i e SansText { a s n d n a i y l s d id: bullet id tr o u s y l i l f u t property real delay: 0.0 o u i g h ct s a i v with } c c h s e i e k hei , c r ght: l paint " edHei a ght P e rf ic m f f r o </b>' width: parent.widthr inte u t t pp e p s i r o a e Q t ed cu text: "" ic us nd + " d avasc a g J m Q > d a + s b n n e < i 1 e y fon t.pixelSize: 36 C t b ld on y dpMode 6 ded p*viewer.height/600.0 i i dt.Wra ck 1. hl wra t m e i 9 u g i u b u i : Tex e m Q s m h b 9 e t 0.00 g"'} in an of or d incity: ort Q r stom, esse opa m1 p ("c d t u f y m c i o e t ' a g d umbin25 r > s r n i l b p f i p a s / w x d " u < l e l l e k E " f uentialAni f r p e g" p i 0 h v f bui >, logic amount o Seq tQuic i d.'}mation { n x KD t o t Q e i i t > 1 l t { y e b r a a a b < b r e w w 0 r u rk eg unning: true ic fo m s ar 2 l g Slid etext: ' r ve" <b>QML</ inimises ly int P e u s i 0 c i l m o t . c l a o . e auseAnimation { s 0 p r n . l a : i , f a " f D as L cl r > m tit " by f e e b t d D / e e > o dura " < tion: 1000*delay M r t b Qt ewo 995; ba .2 in 20 m, until t4.7 i o! b ' g i / t n Q cr o i s< t: din n s t x n e n } e y i r u d e p t b m n . ; e b { I o o 0 d d us m e PropertyAnimation { lets {delay: ;text: 'U >Property C++) comp t e a l fra rted in 1 rom Qt2 or gtkm s in Q nd Maem " sup u a b B i s r b r 2 ( e g t < target: bullet c e s e i s ve ll s : ' f t e ay: i a u t r t l t e B x n e r a m e L e i d N prop n d i erty: "opacity" Sta t a { > g P e n I ia y t <b t 4; i e l d e ' : i i b G l h U y p l : / s a to: p 1.0 m u i t l m B W w g p PL cr ea Sy llet {de ay: 6;tex y s n } a s wx i : r a t LG s d v o u l n e L B u t e n a d } c i e J v { r o M ile f E on ila yb ullet t t p Q B r / b Sim m y e Q BulletIcon {} o k r p " c r o mo c : r ) i ) e g + } } P u stron + t a c kb C ( Q e t e b } la iv Q ially a t n B i a N w and Init o n ( S 2 O . i Qt5 roid, d Pr o An Pr e d n e l b ub im t por QtQ 1.1 { le le s*2.0 0 g n b ta ub iu *2. Rec d: b : rad dius f' ius d i a h f a r idt t: 000 0*r w eigh : '#0 .125 ht+2. h olor ty: 0 heig { on c paci rent. i t ma o : pa Ani ue on { y l a i i tr ent ng: nimat le u q i b e A n b S run perty : bu : "y" t Pro arge ties adius t roper .0*r 5000 ); p o: -2 on: y(0 o r st t urati { e.de d n o ti bbl } iptAc : bu Scr cript s } } } F ul Mandelbrot C++ sources #ifndef _mbrot_h_ #define _mbrot_h_ class Mbrot : public QDeclarativeItem { Q_OBJECT Q_PROPERTY(QPoin tF centre READ centre WRITE setCentre) Q_PROPERTY(qreal radius READ radius WRITE setRadius) Q_PROPERTY(QList <QVariant> colors READ colors WRITE setColors) Q_PROPERTY(bool downsize READ downsize WRITE setDownsize) public: Mbrot(); ~Mbrot(); QPointF centre() const {return _centre;} void setCentre(const QPointF& p) {_centre=p;recal culate();} qreal radius() const {return _radius;} void setRadius(qreal r) {_radius=r;recal culate();} QList<QVariant> colors() const {return _colors;} void setColors(const QList<QVariant>& c) {_colors=c;recal culate();} bool downsize() const {return _downsize;} void setDownsize(bool d) {_downsize=d;if (!_downsize) recalculate();} Q_INVOKABLE void moveCentre(const QPointF&,const QPointF&); Q_INVOKABLE QPointF positionOfPixel( int,int) const; void paint(QPainter* painter,const QStyleOptionGrap hicsItem*,QWidge t*); protected: void geometryChanged( const QRectF&,const QRectF&); private: QImage _image; QPointF _centre; qreal _radius; bool _downsize; QList<QVariant> _colors; void recalculate(); }; #endif b in P r op e r import QtQui Slide { titl etext: func tion h ck 1.1 "Prope ailsto import QtQuick 1.1 imp t y b i nd rty bi nding ne(n) i ng d e m demo" o: s ou r #include "Mbrot.h" #include "MbrotCalculator.h " Mbrot::Mbrot() :_centre(-1.0,0.0) ,_radius(1.0) ,_downsize(false) { setFlag(QGraphicsI tem::ItemHasNoCont ents,false); } Mbrot::~Mbrot() {} void Mbrot::moveCentre( const QPointF& a,const QPointF& b) { _centre+=(b-a); recalculate(); } QPointF Mbrot::positionOfP ixel(int x,int y) const { const double s=_radius/(0.5*std ::min(width(),heig ht())); return QPointF( _centre.x()+s*(x-0 .5*width()), _centre.y()+s*(y-0 .5*height()) ); } sclo s ur e: m #in #in clude clu de "QmlV "Mb iew int rot er. mai { .h" h" n(i n t a QAp rgc pli ,ch cat ar* i qml on arg Reg app v[] ist (ar ) erT gc, Qml y a Vie pe< rgv wer Mbr ); ot> vie vie ("M wer ret wer.s bro ( app } urn how t", . arg 1,0 app (); ume ,"M .ex nts bro ec( (). t") ); mid ; (1) ); void Mbrot::paint(QPain ter* painter,const QStyleOptionGraphi csItem*,QWidget*) { painter->drawImage (QPointF(0.0f,0.0f ),_image); } void Mbrot::geometryCha nged (const QRectF&,const QRectF&) { recalculate(); emit widthChanged(); emit heightChanged(); } l di ce void Mbrot::recalculate () { MbrotCalculator mbrot( width()/(_downsize ? 2 : 1),height()/(_down size ? 2 : 1), _centre.x(),_centr e.y(),_radius,256, _colors ); _image=(_downsize ? mbrot.image().scal ed(width(),height( )) : mbrot.image()); update(); } ai n . cp p i d l u s o scl Q : re ie V l m d) ) nge ged Cha Chan ) h t _ d) id ght ed r_h nge Y w hei ang ara ewe r_h_ Cha TIF IFY ideCh ecl i s O D v d N Q e on h NOT Y sl T) qml iew lic sec F idt ht N f _ mlv pub D w heig NOTI NSTA TIFY nde e _q A : f E O i # fin h R EAD slide es C ds NO wer n idt t R Vie #de id t w eigh READ D sl seco Qml T n i s C Y( t h de REA AD s E a J cl _OB PERT (in sli es s RE Q RO RTY nt lid nd ; Q_P ROPE RTY(i nt s seco g&) rin Q_P ROPE RTY(i real t S ; q P &) Q_ ROPE RTY( t Q ist ons Q_P ROPE ngL s(c i P t r _ n Q St te t Q Con } ons ic: ile c l F ( b t (); r ; pu ge gth ewe er() } g n i ; n e V w } de .l ri Qml lVie sli des ds; QSt n _ _sli secon LE ~Qm r B u A _ K ret urn n NVO ); ) { ret tur Q_I nt* ); de( () { ) {re i Eve ent* l s s( y s e e v d (QK zeE int sli econd ent esi int al s sEv t(QR s e e r r q en eyP eEv d k siz voi d re voi ); ts: er( slo ); Tim ; ic e l rl& l b ) pu ogg (int st QU t n d ve voi d mo ad(co ; voi d lo int() voi d pr t); voi (in t); &); ged d(in ); : n s ing a l e na hCh hang d(int nt); QStr t d sig t e i (i tC d w igh ang ged ons voi d he ideCh Chan ged(c ; s i n l ) d o v d s con Cha sc( voi d se ntent KeyE voi d co essed voi d pr voi F ul eV tiv iew { & ist sli des pe r ty b r e w h" i ng de m More good Qt stuff es) 122 QML element types (+7 modul "QtQuick Controls" s, me QML elements for desktop: dialog nus, layouts QtWebKit/QtWebEngine QmlWeb: webapps via DOM & CSS QtConcurrent C++ generic map/reduce, QFuture PyQt/PySide: Qt python bindings Superb documentation ffec and e o: B ) L ing Str ); Q ect st Obj ; con lVi t ( m o r Q ) " oRo ing ewe 0) de ewT ias lVi ew( clu eVi tial :Qm veVi z : #in ; i r n ); we ati ()) ::S tyA ()) Vie lar mat s) iew uali r V o uit e Qml QDec de(0) lide F Q q v t h ( i l g : li s(s OT at Hi au ,SL lar r:: ,_s lide ds(0) ; def e() ; Dec inte ))) s); t:: ); )); c Q ; i a ,_s econ n ( ) ) h m a a e e QP ng& ) st ()) t r ru mat d s i ) , o o _ r ( " F ( , eM ts St nt :in en ; er GL s(t or siz in t Q pri on: cre ))) iew t(Q fer l_f { etRe nderH ons OT( cati FullS mal( ("v rma eBuf get(g ; c L y o ) s Re ( S t f ) r le s, pli ow No er l_ mpl id () set Tit thi eAp (sh how rop t g tSa GLW mer dow )), QCor ,SLOT OT(s xtP rma t.se new Q eTi n ( e o l i P t F g L , a og etW Key ()) his s,S Con QGL form port( T(t ); T(s sed eyQ ),t thi set gl_ View SLO k()) SLO res sedK eyF() ()), ; )-> , , p ) ( t s s c ( ] t e x s hi AL res dK Esc de thi (ti nte ),t IGN L(p sse Key sli )), LOT tCo g&) s,S IGNA L(pre ssed s[_ ce( is,S n i e a i h d roo p e S r NA pr (t s, yS ,th sli QSt ect thi SIG AL( dKe ()) d(_ nst onn ect( this, SIGN sse eout o c loa e c : r , n t( is t: on (p tim ed( jec ::c nec (th NAL AL( ang QOb ject ::con nect SIG SIGN tCh , n s n b e , t QO jec ::co nt thi ock (co ct( _cl QOb ject NAL nne ct(& G o I c QOb e ,S t:: onn his jec ::c t(t { c QOb ject e nt) onn QOb eve ::c t * c t ); je en er( QOb yEv {} Tim QKe () e ( r l t e g { en ew tog sEv _F) lVi { res :Key ~Qm P : y : } : P) e r t ey_ ::k )==Q ); ewe K r i : e V : ( w y( Qml =Qt Vie >ke eyF Qml ent- ssedK (); ey()= d t v k e i vo f (e t pr ccep nt-> ); i mi ->a ve yP( e nt (e Ke eve e if essed s r l p } e mit e r. ewe i nd ort Qt Qui Rec ck t a i ngl 1.1 d e : y ba { : r w par h idth: ent.h c eight pare eight o olor: : par nt.wi -heig pac '# ent dth ht ity 00f .he /(1 : 0 f00 igh .0+ p .9 ' t*v par rop alu ent ert e/2 .ch y i B 50. ild n e t va 0 ren havi lue .le Para or on : 0 ngt h) Pr llelA heig Pr opert nimat ht { opert yAnim ion { targe yAnim ation prope t: ba ation {} { from: rty: r } to: ' '#ff "colo #00 000 r" } } ff0 0' 0' S ansTe anch xt { anch ors.b font ors.h ottom } text .pixe orizo : par : p lSi nta ent } are ze: lCe .bo nt. 24 nte tto val .0* r: m ue. vie par toS wer ent tri .he .ho ng( igh riz ) t/6 ont 00. alC 0 ent er Keys {retur . n (n%2 if onPressed: ==0 ? (even { n/2 : el t.key= 3*n+1 se if =Qt.Ke );} // } (event y_Up & Gener .key== & ates n Row Qt.Key bar0.value ext nu { _ < mber i Down & 100) { an n "Hai & bar0 bar0.v chors. lstone .value alue++ an horizo " sequ >1) {b ; c n ence ar0.va event.accep wi hors.vertic talCenter: l t u e e d = dth: 0 alCent t p ;event rue;} he .95*pa er: pa arent.horiz . a c c e ight: rent.w p r on ted=tr ent.ve sp 0.95*p i ue;} rtical talCenter a arent. dth Center Ba cing: 2 bodyHe r {id: i g h t Ba bar0 r ; Ba {id: bar1 value: 42;} r {id: ; Ba bar2 value: hail r ; Ba {id: bar3 value: hail stone( bar0 // . r ; Ba {id: bar4 value: hail stone( bar1 value);} // First bar v . Subse r a ; Ba {id: bar5 value: hail stone( bar2 value);} quent lue is unde . r bars' ; r Ba {id: bar6 value: hail stone( bar3 value);} values keyboard c . r ; calcu o Ba {id: bar7 value: hail stone( bar4 value);} lated ntrol . r ; from p Ba {id: bar8 value: hail stone( bar5 value);} recedi . r ; ng nei Ba {id: bar9 value: hail stone( bar6 value);} ghbour . r {id: ;value s v t a o l ne( ba ue);} Ba bar10 : hail r7.val r {id: ;value s t o ne( ba ue);} Ba bar11 : hail r8. r ; Ba {id: bar12 value: hail stone( bar9 value);} . r {id: ;value s v t a o lue);} ne(bar Ba bar13 : hail 10. r ; Ba {id: bar14 value: hail stone(bar11 value);} . r {id: ;value s v t a one(b lue) } bar15 : ;value hailstone( ar12.value) ;} } : hail b ; stone( ar13.value) } bar14. ; value) } ;} l m .q k uic r ty Ob d ject i ng b ou pr o nd pe r t pro o a ties per ca n Jav ty's va l ue a v al Scr be a of t Ma he ue is a ipt ssig e va uto ssiv e l xpr ned nee e re uated e matica e ss sta l xp r de d duc ess ly upd ion tic v t i sign a o i ted n ch on alu al / s a b i n y es, na lo t ges the QM wir mo or QM ing, Le L u eng or o nt o ngi P ro ine nPr n f "p wh ed ope pe r ene rty ete l u ties ve r C mb han c the t sd ged ca n i n g "/ : ha e pe be n " wi d le r s nde re- b ring ncy oun " loo dd ps yna mic ally l } } c om o " ti e p o l ve nt e m op e Item .1 id { : an bubb chors. les fill Ti : pa rent mer { i nterv runnin al: 50 repeat g: tru } onTrig : true e gere d: { if ( fu Math n c tion .ran dom( var r= launc )<0. h b var x= ubble () { 1) l aunc var co -radiu s.heig h(); h s m v t } } ar bu ponen +bubb *Math l t b . e = b r s le=c Qt.c a . } ompo reat width* ndom() nent eCom Math *0.1 .cre pone .ran ; ateO nt(" dom( bjec Bubb ); t(bu le.q bble ml") s,{" ; radi us": r,"x Slide.qml ... ute ap p an in / tes eng tsuit GU I t ine" e r e. E prog a c Uns asy. tive r am atisf m i d n emo Wha actory "plu g is fiddly a pp and gin" t i . Pr tedi ar c h smo f ther ous itect oble othl e wa ures ms: dy n y s m a a mi i c we xing C+ framew + co o b-in mpo rk desi flue nced gne nen t s int d aro syst u em for U o a mod nd ern I cr e atio n? C+ + C ++ a c he ) " T . Q r" ar . q ts'} ml