Académique Documents
Professionnel Documents
Culture Documents
http://www.pelagicore.com/documents/2011-Apr-QtWorkshop.odp
2011 Nokia Corporation and its Subsidiary(-i s!. "h nc#os d Qt $at ria#s ar pro%id d und r th Cr ati% Co&&ons Attribution-Shar A#ik 2.' (ic ns A)r & nt.
"h *u## #ic ns t +t is a%ai#ab# h r , http,--cr ati% co&&ons.or)-#ic ns s-by-sa-2.'-# )a#cod . Nokia. Qt and th Nokia and Qt #o)os ar th r )ist r d trad &arks o* Nokia Corporation in /in#and and oth r countri s 0or#d0id .
"h 1r s nt r
2ohan "h #in 34ohan.th #in5p #a)icor .co&6
Cr at s &idd# 0ar *or in-% hic# in*otain& nt bas d on $ 7o "h sis 0ork 0ithin &b dd d (inu+. op n sourc and d si)n
What is Qt8
Qt is a cross platform development framework written in C++.
What is Qt8
Qt is &ad up o* &odu# s
A## &odu# s ha% a co&&on sch & and ar bui#t *ro& th sa& A1I d si)n id as
QtCore QtGui
Qt=p n7( QtW b@it Qt=p nC7 QtSB# QtS%) QtScript Qt?att rns Qt$u#ti& dia QtN t0ork Qt?&# 1honon
What is Qt8
%% returns &QPushButton&
Windo0s
$ac =S ?
(inu+-Ani+ ?11
D ##o Wor#d
D ##o Wor#d
.inclu,e /Q*00lication" .inclu,e /QLabel" int #ain( int ar1c, char **ar1v ) { Q*00lication a00( ar1c, ar1v ) QLabel l( 23ello 4orl,52 ) l6show() return a006e7ec() }
D ##o Wor#d
#include <QApplication> #include <QLabel> int #ain( int ar1c, char **ar1v ) { Q*00lication a00( ar1c, ar1v ) QLabel l( 23ello 4orl,52 ) l6show() return a006e7ec() }
D ##o Wor#d
.inclu,e /Q*00lication" .inclu,e /QLabel" int #ain( int ar1c, char **ar1v ) { QApplication app( argc, argv ); QLabel l( 23ello 4orl,52 ) l6show() return a006e7ec() }
D ##o Wor#d
.inclu,e /Q*00lication" .inclu,e /QLabel" int #ain( int ar1c, char **ar1v ) { Q*00lication a00( ar1c, ar1v ) QLabel l( "Hello World!" ); l. !o"(); return a006e7ec() }
D ##o Wor#d
.inclu,e /Q*00lication" .inclu,e /QLabel" int #ain( int ar1c, char **ar1v ) { Q*00lication a00( ar1c, ar1v ) QLabel l( 23ello 4orl,52 ) l6show() return app.e#ec(); }
"h Q=b4 ct
QObject instances are individuals!
"h y can ha% a na& (QObject88object$a#e! "h y ar p#ac d in a hi rarchy o* QObject instanc s "h y can ha% conn ctions to oth r QObject instanc s E+a&p# , do s it &ak s ns to copy a 0id) t at run-ti& 8
$ ta data
Qt i&p# & nts introsp ction in C99 E% ry QObject has a meta object "h & ta ob4 ct kno0s about
c#ass na& (QObject88class$a#e! inh ritanc (QObject88inherits! prop rti s si)na#s and s#ots ) n ra# in*or&ation (QObject88class(nfo!
QObject
,elete 0arent
As th
this!point
r as top # % # par nt
<ialo188<ialo1(Q4i,1et *0arent) 8 Q<ialo1(0arent) { Q)rou0Bo7 *bo7 = Q)rou0Bo7(this) QPushButton *button = QPushButton(this) Q=a,ioButton *o0tion9 = Q=a,ioButton(bo7) Q=a,ioButton *o0tion: = Q=a,ioButton(bo7) 666
D ap
Wh n usin) new and ,elete. & &ory is a##ocat d on th h ap. D ap & &ory &ust b +p#icit#y *r d usin) ,elete to a%oid & &ory # aks. =b4 cts a##ocat d on th h ap can #i% *or as #on) as th y ar n d d.
new
Construction
Destruction
,elete
Stack
(oca# %ariab# s ar a##ocat d on th stack. Stack %ariab# s ar auto&atica##y d struct d 0h n th y )o out o* scop . =b4 cts a##ocat d on th stack ar a#0ays d struct d 0h n th y )o out o* scop .
int a
Construction
Destruction
}
Stack and D ap
"o ) t auto&atic & &ory &ana) & nt. on#y th par nt n ds to b a##ocat d on th stack.
>?>ain4in,ow Q*00lication
int #ain(int ar1c, char **ar1v) { Q*00lication a(ar1c, ar1v) >?>ain4in,ow w w6show() return a6e7ec() }
>yna&ica##y and #oos #y ti to) th r % nts and stat chan) s 0ith r actions What &ak s Qt tick
clear()
connect(clearButton,'()$*L(clic+e,()),list4i,1et,'LO-(clear()))
}
{ 666 e#it clic+e,() 666 }
}
{ 666 e#it clic+e,() 666 }
clear()
What is a s#ot8
A s#ot can r turn %a#u s. but not throu)h conn ctions Any nu&b r o* si)na#s can b conn ct d to a s#ot
connect(src, '()$*L(si1()), ,est, 'LO-(slt()))
It is i&p# & nt d as an ordinary & thod It can b ca## d as an ordinary & thod
What is a si)na#8
A si)na# can b conn ct d to any nu&b r o* s#ots Asua##y r su#ts in a dir ct ca##. but can b pass d as % nts b t0 thr ads. or % n o% r sock ts (usin) Frd party c#ass s! "h s#ots ar acti%at d in arbitrary ord r A si)na# is &itt d usin) th
e#it a'i1nal()
&it k y0ord
A signature consists of the function name and argument types. No variable names, nor values are allowed.
set-itle(Q'trin1 te7t) setBalue(C:) set(te#((te#Alass) clic+e,() to11le,(bool) set-e7t(Q'trin1) te7tAhan1e,(Q'trin1) ran1eAhan1e,(int,int)
Slots
set=an1e(int,int) setBalue(int) u0,ate<ialo1() set=an1e(int,int) setBalue(int) u0,ate<ialo1() setBalue(int) setBalue(int) u0,ate<ialo1()
Wh n usin) > si)n r it is con% ni nt to ha% auto&atic conn ctions b t0 n th int r*ac and your cod
on; object name ; signal name ( signal parameters )
on;a,,Button;clic+e,() on;,eleteButton;clic+e,() on;list4i,1et;current(te#Ahan1e,(QList4i,1et(te#*,QList4i,1et(te#*)
Co&par
on;wi,1et;si1nal
to u0,atePa1e>ar1ins
updat 1a) $ar)ins can b conn ct d to a nu&b r o* si)na#s or ca## d dir ct#y.
7oa# o* th day
>ocu& nt 0indo0(s! >ia#o)s $ nus. too#bars. statusbars Gasic *i# &ana) & nt =p n. Sa% and Sa% As
7oa# o* th day
Cr atin) a pro4 ct
In QtCr ator. cr at a Qt !ui Application pro4 ct As th Qt"ore and Qt!ui &odu# s Gas th sk # ton pro4 ct on a Q>ain4in,ow
Cr atin) a pro4 ct
-e7t@,itor60ro : th pro4 ct
d *inition *i#
#ainwin,ow6ui : th us r
#ainwin,ow6h%c00 : th c#ass
"h p#an
"his # ctur 0i## bui#d a t +t ditor in an it rati% proc ss / atur s 0i## b add d to th app#ication. 0hi# &aintainin) a *unctionin) app#ication throu)hout th proc ss "his is ho0 &ost so*t0ar is b in) bui#t in r a# #i* H
Jou ha% to d s # ct and r s # ct th c ntra# 0id) t to s th s prop rti s a*t r you ha% app#i d th #ayout
Addin) actions
t +t ditin) c ntra# 0id) t in p#ac . th p 0i## b to # t th us r cr at n 0 nts. c#os th curr nt docu& nt and to app#ication
Why QAction
Action
Ctrl S
Why QAction
A Q*ction ncapsu#at s a## s ttin)s n d d *or & nus. too# bars and k yboard shortcuts Co&&on#y us d prop rti s ar
te7t : th t +t us d % ry0h r icon : icon to b us d % ry0h r shortcut : shortcut chec+able-chec+e, : i* th action is ch ckab# and
th curr nt ch ck status
Why QAction
Q*ction *action = new Q*ction(parent) action!"set-e7t(2te7t2) action!"set(con(Q(con(28%icons%icon60n12)) action!"set'hortcut(QDe?'eEuence(2AtrlF)2))
Cr atin) a n 0 action S ttin) prop rti s *or t +t. icon and k yboard short-cut A QCariant can b associat d 0ith ach action. to carry data associat d 0ith th )i% n op ration
action!"set<ata(#?<ataQBariant)
Why QAction
Addin) a n 0 action brin)s up a dia#o) 0ith th d tai#s (na& . t +t. tips...! Action icons can b add d ith r *ro& *i# s or r sourc s
Icon r sourc s
A%oid ha%in) to d p#oy &u#tip# *i# s No n d to tryin) to d t r&in th path *or th icons *or ach sp ci*ic insta## typ A## *its n at#y into th bui#d syst & ... Jou can add anythin) into r sourc s. not on#y icons
Addin) a r sourc *i# to a pro4 ct is 4ust as addin) any sourc *i# to a pro4 ct Wh n ha%in) add d th r sourc *i# . &ak sur to c#os any > si)n r *or&s and r -op n th & *or > si)n r to disco% r th r sourc
Addin) r sourc s
=p nin) th r sourc *i# )i% s you th r sourc *i# ditor G *or any r sourc s can b add d to th r sourc *i# . you &ust *irst cr at a dir ctory in th r sourc *i# In this cas 0 put icons into th -icons dir ctory
Addin) actions
/ro& > si)n r. you can no0 pick an icon *or th actions that you p#an to sho0 in too#bars C#ick K...L n +t to th icon s ttin) 1ick KChoos ; sourc ...L
Addin) actions
Wh n you ha% add d your actions to th action ditor. you n d to add th & to th *or&
Addin) actions
"o add th & to a & nu. doub# c#ick on K"yp h r L and nt r th & nu tit# . th n dra) and drop action onto th & nu
Addin) actions
In this *irst it ration. 0 add th &ost basic actions Name #con Short$cut !ool$tip
actionN 0 actionC#os actionE+it Ctr#9N Ctr#9W Cr at a n 0 docu& nt C#os curr nt 0indo0 E+it app#ication
"h na& is auto&atica##y ) n rat d 0h n nt rin) th t +t *or th action C#os and E+it ar add d to th & nu.
"o add a s parator. doub# c#ick KAdd S paratorL th n dra) it into p#ac .
Gy ri)ht c#ickin) on th action in th action ditor. you can )o th corr spondin) s#ot S#ots ar ) n rat d on th *#y in both h ad r and i&p# & ntation I&p# & ntin) th n 0 s#ot is asy : 4ust cr at a n 0 >ain4in,ow and sho0 it
voi, >ain4in,ow88on;action$ew;tri11ere,() { >ain4in,ow *w = new >ain4in,ow() w!"show() }
Status updat
No0. 0 ha% a 0indo0 0ith a 0orkin) t +t ditin) 0id) t N 0 0indo0s can b cr at d Windo0s can b c#os d "h app#ication can +it (i. . c#os a## 0indo0s!
No0. th 0indo0s c#os r )ard# ss o* th ir cont nts "h +p ct d b ha%ior 0ou#d b to ask th us r b *or c#os a &odi*i d docu& nt "o i&p# & nt this. 0 add a &odi*i d *#a) 0hich is s t 0h n % r th t +t o* th Q-e7t@,it is chan) d W a#so int rc pt c#os % nts and ask th us r b *or c#osin) &odi*i d % nts
C#osin) sa* #y
Acc pt & ans that th 0indo0 0i## c#os (and b d # t d in this cas ! I)nor & ans that th 0indo0 0i## r &ain op n
A## % nts ar hand# d in th QObject88event & thod pro%id s %irtua# & thods *or th &ost co&&on % nts. .). Q4i,1et88close@vent
Q4i,1et
C#osin) sa* #y
; -i&p# & ntin) th close@vent & thod to ask th us r b *or c#osin) a 0indo0 0ith a &odi*i d docu& nt
voi, >ain4in,ow88close@vent(QAlose@vent *e) { if(#;#o,ifie,) { if(Q>essa1eBo788warnin1(this, 2<ocu#ent >o,ifie,2, 2-he ,ocu#ent has been #o,ifie,, ,o ?ou want to close itHIn2 2Jou will lose all ?our chan1es62, Q>essa1eBo788Jes K Q>essa1eBo788$o, Q>essa1eBo788$o) == Q>essa1eBo788Jes) { e!"acce0t() } else { > p ndin) on th e!"i1nore() us rNs ans0 r. th } % nt is acc pt d } else { or i)nor d e!"acce0t() } }
Q$ ssa) Go+
dia#o)s dia#o)s
;ou)h#y th sa& typ o* dia#o)s 0ith a tit# . a & ssa) and on or &or buttons.
infor#ation warnin1
dia#o)s dia#o)s
critical about
Q$ ssa) Go+
1ar nt 0indo0 >ia#o) tit#
Q>essa1eBo788warnin1(this, 2<ocu#ent >o,ifie,2, 2-he ,ocu#ent has been #o,ifie,, ,o ?ou want to close itHIn2 2Jou will lose all ?our chan1es62, Q>essa1eBo788Jes K Q>essa1eBo788$o,
"h buttons to us . 1ick *ro& (k. (pen. )a*e. "ancel. "lose. +iscard. Appl,. -eset. -estore de.aults. /elp. )a*e all. 0es. 0es to all. 1o. 1o to all. Abort. -etr, and 2gnore
Q>essa1eBo788$o) == Q>essa1eBo788Jes
Wh n is a docu& nt &odi*i d8
"h us r +p cts to s i* a docu& nt is &odi*i d or not *ro& th tit# o* th 0indo0 Gy s ttin) a 0indo0 tit# 0ith th sub-strin) KL*ML. th &odi*i d indication can b acti%at d usin) set4in,ow>o,ifie,. "his *unction is ca## d
*ro& th constructor as 0 ## as *ro& th ,ocu#ent>o,ifie, s#ot
App#ication na&
Wh n bui#din) th tit# . 0 us d th Q*00lication88a00lication$a#e & thod "h Q*00lication ob4 ct k ps track o* th app#icationNs na& . % rsion. produc r. tc. "his is us d *or 0indo0 tit# s. tc t ra
a6set*00lication$a#e(2-e7t @,itor2) a6set*00licationBersion(2O692) a6setOr1aniPation$a#e(2@7a#0le'oft2) a6setOr1aniPation<o#ain(2e7a#0le6co#2) App#ication na& and % rsion 1roduc r na& and do&ain App#ication icon
a6set4in,ow(con(Q(con(28%icons%new60n12))
Status updat
No0. 0 ha% a 0indo0 0ith a 0orkin) t +t ditin) 0id) t N 0 0indo0s can b cr at d Windo0s can b c#os d "h app#ication can +it (i. . c#os a## 0indo0s!
W can k
S # ctin) a *ont
"h standard *ont o* th t +t ditor is % ry Kp#ainL. "o r & dy. 0 0i## # t th us r pick th *ont W add an action. add a Ci 0 & nu and put th action in th & nu
Name
actionS # ct/ont
!e"t S # ct /ont...
#con
Short$cut
N 0 & nus ar a#0ays p#ac d to th ri)ht. but th y can b dra)) d in to p#ac a*t r0ards
S # ctin) a *ont
voi, >ain4in,ow88on;action'electQont;tri11ere,() { bool o+ QQont font = QQont<ialo1881etQont(Ro+, ui!"te7t@,it!"font(), this) if(o+) ui!"te7t@,it!"setQont(font)
"h boo# an. o+. is us d to d t r&in i* th us r actua##y pick d a *ont. "his is b caus QQont %a#u s a#0ays ar %a#id.
$or on *onts
Asin) th curr nt i&p# & ntation. ach 0indo0 pops up 0ith th d *au#t *ont and th us r has to pick a n 0 *ont "h us r +p cts s ttin)s to stick. i. . us th #ast %a#u 0h n op nin) n 0 0indo0s
QS ttin)s
S ttin)s ar stor d di** r nt#y on a## &a4or p#at*or&s Gy usin) a Q'ettin1s ob4 ct. you ) t a cross p#at*or& int r*ac *or handin) s ttin)s
Q'ettin1s settin1s #?'trin1 = settin1s6value(2+e?2,2,efault2)6to'trin1() settin1s6setBalue(2+e?2, #?'trin1) settin1s6re#ove(2+e?2)
Any QBariant can b stor d : but think about r adabi#ity *or ad%anc d us rs
Gack to th *ont
Sa%in) th *ont
voi, >ain4in,ow88on;action'electQont;tri11ere,() { bool o+ QQont font = QQont<ialo1881etQont(Ro+, ui!"te7t@,it!"font(), this) if(o+) { Q'ettin1s settin1s settin1s6setBalue(2viewQont2, font) ui!"te7t@,it!"setQont(font) } }
; storin) th *ont
>ain4in,ow88>ain4in,ow(Q4i,1et *0arent) 8 666 { 666 > *au#t %a#u Q'ettin1s settin1s ui!"te7t@,it!"setQont( settin1s6value(2viewQont2, Q*00lication88font())6value/QQont"()) 666
Custo& *ontsH
Status updat
No0. 0 ha% a 0indo0 0ith a 0orkin) t +t ditin) 0id) t N 0 0indo0s can b cr at d Windo0s can b c#os d "h app#ication can +it (i. . c#os a## 0indo0s! W can k p track o* docu& nt &odi*ications
"h
dit & nu
asy to add
!ool$tip Cut Copy 1ast #con Short$cut Ctr#9? Ctr#9C Ctr#9C
"h
dit & nu
"o a%oid tryin) to copy in %ain. # tNs add conn ctions *or nab#in) and disab#in) th actions d p ndin) on th s # ction
connect(ui!"te7t@,it, '()$*L(co0?*vailable(bool)), ui!"actionAut, 'LO-(set@nable,(bool))) connect(ui!"te7t@,it, '()$*L(co0?*vailable(bool)), ui!"actionAo0?, 'LO-(set@nable,(bool)))
Andoin)
Addin) support *or undo and r do is 4ust as asy as *or th c#ipboard op rations
Name actionAndo action; do #con Short$cut Ctr#9O Ctr#9J !ool$tip Ando th #ast action ; do th #ast action
!e"t Ando ; do
connect(ui!"actionGn,o, '()$*L(tri11ere,()), ui!"te7t@,it, 'LO-(un,o())) connect(ui!"action=e,o, '()$*L(tri11ere,()), ui!"te7t@,it, 'LO-(re,o())) connect(ui!"te7t@,it, '()$*L(un,o*vailable(bool)), ui!"actionGn,o, 'LO-(set@nable,(bool))) connect(ui!"te7t@,it, '()$*L(re,o*vailable(bool)), ui!"action=e,o, 'LO-(set@nable,(bool)))
Status updat
No0. 0 ha% a 0indo0 0ith a 0orkin) t +t ditin) 0id) t N 0 0indo0s can b cr at d Windo0s can b c#os d "h app#ication can +it (i. . c#os a## 0indo0s! W can k p track o* docu& nt &odi*ications
A 0indo0 cannot b c#os d 0ithout acc ptin) th #oss o* docu& nt &odi*ications As r con*i)urab# *onts 1 rsist nt us r s ttin)s
"h
Ando and r do
Anti# no0. docu& nts can b &odi*i d. but n % r un&odi*i d Wh n is th &odi*i d *#a) c# ar d8
QQile file(#;file$a#e) if(5file6o0en(Q(O<evice88=ea,Onl? K Q(O<evice88-e7t)) EQatal(2@rror o0enin1 file for rea,in12) Q-e7t'trea# in(Rfile) in "" te7t'trin1
Sa%in)
QQile file(#;file$a#e) if(5file6o0en(Q(O<evice884riteOnl? K Q(O<evice88-e7t)) EQatal(2@rror o0enin1 file for writin12) Q-e7t'trea# out(Rfile) out // te7t'trin1
I* ord r to i&p# & nt *i# op rations. ach docu& nt 0indo0 &ust ha% a *i# na& As a start. it is s t in th constructor
MainWindow::MainWindow(const QString &fileName, QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), m_modified(false), m_fileName(fileName) !!! if("m_fileName!isNull()) load#ile()$ updateWindow%itle()$
&
; su#ts in,
untitle,* ! -e7t @,itor testin16t7t ! -e7t @,itor
>ocu& nts ar #oad d *ro& th loa,Qile & &b r *unction It att &pts to #oad th curr nt *i# I* it *ai#s. it s ts th curr nt *i# na& to nu##
voi, >ain4in,ow88loa,Qile() { QQile file(#;file$a#e) if(5file6o0en(Q(O<evice88=ea,Onl? K Q(O<evice88-e7t)) { Q>essa1eBo788warnin1(this, Q*00lication88a00lication$a#e(), tr(2Aoul, not o0en file N96InN:2) 6ar1(QQile(nfo(#;file$a#e)6file$a#e()) 6ar1(file6error'trin1())) #;file$a#e = Q'trin1() } else { Q-e7t'trea# in(Rfile) ui!"te7t@,it!"set-e7t(in6rea,*ll()) } #;#o,ifie, = false u0,ate4in,ow-itle() }
>ocu& nts ar #oad d *ro& th loa,Qile & &b r *unction It att &pts to #oad th curr nt *i# I* it *ai#s. it s ts th curr nt *i# na& to nu##
voi, >ain4in,ow88loa,Qile() { QQile file(#;file$a#e) if(5file6o0en(Q(O<evice88=ea,Onl? K Q(O<evice88-e7t)) { Q>essa1eBo788warnin1(this, Q*00lication88a00lication$a#e(), tr(2Aoul, not o0en file N96InN:2) 6ar1(QQile(nfo(#;file$a#e)6file$a#e()) 6ar1(file6error'trin1())) #;file$a#e = Q'trin1() } else { Q-e7t'trea# in(Rfile) ui!"te7t@,it!"set-e7t(in6rea,*ll()) } #;#o,ifie, = false u0,ate4in,ow-itle() }
>ocu& nts ar #oad d *ro& th loa,Qile & &b r *unction It att &pts to #oad th curr nt *i# I* it *ai#s. it s ts th curr nt *i# na& to nu##
voi, >ain4in,ow88loa,Qile() { QQile file(#;file$a#e) if(5file6o0en(Q(O<evice88=ea,Onl? K Q(O<evice88-e7t)) { Q>essa1eBo788warnin1(this, Q*00lication88a00lication$a#e(), tr(2Aoul, not o0en file N96InN:2) 6ar1(QQile(nfo(#;file$a#e)6file$a#e()) 6ar1(file6error'trin1())) #;file$a#e = Q'trin1() } else { Q-e7t'trea# in(Rfile) ui!"te7t@,it!"set-e7t(in6rea,*ll()) } #;#o,ifie, = false u0,ate4in,ow-itle() }
>ocu& nts ar #oad d *ro& th loa,Qile & &b r *unction It att &pts to #oad th curr nt *i# I* it *ai#s. it s ts th curr nt *i# na& to nu##
voi, >ain4in,ow88loa,Qile() { QQile file(#;file$a#e) if(5file6o0en(Q(O<evice88=ea,Onl? K Q(O<evice88-e7t)) { Q>essa1eBo788warnin1(this, Q*00lication88a00lication$a#e(), tr(2Aoul, not o0en file N96InN:2) 6ar1(QQile(nfo(#;file$a#e)6file$a#e()) 6ar1(file6error'trin1())) #;file$a#e = Q'trin1() } else { Q-e7t'trea# in(Rfile) ui!"te7t@,it!"set-e7t(in6rea,*ll()) } #;#o,ifie, = false u0,ate4in,ow-itle() }
Jou can sp ci*y ar)u& nts in th ;un S ttin)s. und r th pro4 ct tab in QtCr ator
/i# typ *i#t rs can contain s % ra# *i# +t nsions, 2<ocu#ent (*6t7t *6rtf *6,oc)2 Gut a#so s % ra# docu& nt typ s, 2<ocu#ent (*6t7t) (#a1es (*60n1)2
voi, >ain4in,ow88on;actionO0en;tri11ere,() { Q'trin1 file$a#e = QQile<ialo1881etO0enQile$a#e(this, 2O0en ,ocu#ent2, Q<ir88currentPath(), 2-e7t ,ocu#ents (*6t7t)2) if(5file$a#e6is$ull()) { >ain4in,ow *w = new >ain4in,ow(file$a#e) w!"show() }
W can a%oid op nin) a n 0 0indo0 i* th curr nt on is un&odi*i d and 0ithout *i# na&
voi, >ain4in,ow88on;actionO0en;tri11ere,() { Q'trin1 file$a#e = QQile<ialo1881etO0enQile$a#e(666) if(5file$a#e6is$ull()) { if(5#;#o,ifie, RR #;file$a#e6is$ull()) { #;file$a#e = file$a#e loa,Qile() } else { >ain4in,ow *w = new >ain4in,ow(file$a#e) w!"show() } } }
)a*e 0ithout a na& # ads to )a*e As )a*e As s ts a na& and att &pts to sa% )a*e is on o* th options 0h n a &odi*i d docu& nt is c#os d )a*e As can b canc # d Sa%in) can *ai#
QQile file(#;file$a#e) if(5file6o0en(Q(O<evice884riteOnl? K Q(O<evice88-e7t)) { Q>essa1eBo788warnin1(666) #;file$a#e = Q'trin1() I* th *i# cannot b u0,ate4in,ow-itle() return false op n d *or 0ritin). } 0 disp#ay a 0arnin) Q-e7t'trea# out(Rfile) out // ui!"te7t@,it!"toPlain-e7t() #;#o,ifie, = false u0,ate4in,ow-itle() return true
Sa% th docu& nt
"h & thod saveQile*s n % r ca##s saveQile un# s 5file$a#e6is$ull() thus th r is no risk *or in*init r cursion
As sa% and sa% as not ar auto&atica##y conn ct d s#ots. th y n d to b conn ct d to th corr spondin) actions in th constructor
connect(ui!"action'ave, '()$*L(tri11ere,()), this, 'LO-(saveQile())) connect(ui!"action'ave*s, '()$*L(tri11ere,()), this, 'LO-(saveQile*s()))
Status updat
No0. 0 ha% a 0indo0 0ith a 0orkin) t +t ditin) 0id) t N 0 0indo0s can b cr at d Windo0s can b c#os d "h app#ication can +it (i. . c#os a## 0indo0s! W can k p track o* docu& nt &odi*ications
A 0indo0 cannot b c#os d 0ithout acc ptin) th #oss o* docu& nt &odi*ications As r con*i)urab# *onts 1 rsist nt us r s ttin)s "h +p ct d c#ipboard actions, cut. copy and past
Ando and r do
"hank you *or your att ntionH 4ohan.th #in5p #a)icor .co&