[Qt-interest] Qt-interest Digest, Vol 12, Issue 13

John McClurkin jwm at nei.nih.gov
Tue Nov 3 14:00:55 CET 2009


Mystical Groovy wrote:
> please excuse my english but if i understand correctly the only think 
> ill get from redesigning the whole application and creating a class that 
> stores the applications data will be a more readable code.

You don't just get more readable code, you get a more flexible, scalable 
application.

> 
> i mean, the QString that will be declared in -for e.x- "appsData" class, 
> will have to be easilly accessible from checkRepo class, and from 
> mainwindow class.
> 
> I dont have a problem creating a whole new slot at checkRepo class to 
> handle changes of the QString, because its only one string in a whole 
> application that needs to be used outside the class that it declared the 
> first place, but what im going to do if as the app developed further and 
> the need of a such string from one grows to 20?

That is exactly the advantage of a separate data class.

> 
> i hope you get the meaning :)
> 
> 2009/11/3 Ross Driedger <ross at earz.ca <mailto:ross at earz.ca>>
> 
>     On Mon, 02 Nov 2009 16:44:41 -0500,
>     <qt-interest-request at trolltech.com
>     <mailto:qt-interest-request at trolltech.com>>
>     wrote:
> 
>      > Message: 2
>      > Date: Mon, 2 Nov 2009 22:49:55 +0200
>      > From: Mystical Groovy <mysticalgr at gmail.com
>     <mailto:mysticalgr at gmail.com>>
>      > Subject: [Qt-interest] declaring QString globally
>      > To: qt-interest at trolltech..com <mailto:qt-interest at trolltech.com>
>      > Message-ID:
>      >      
>     <4877b36e0911021249m3285102bsb7069efdfa29a439 at mail.gmail.com
>     <mailto:4877b36e0911021249m3285102bsb7069efdfa29a439 at mail.gmail.com>>
>      > Content-Type: text/plain; charset="iso-8859-1"
>      > hello all,
>      > I have a question
>      > I have 3different classes on my app,
>      > lets say
>      > mainclass.cpp/h, preferencesdialog.cpp/h, checkrepo.cpp/h
>      > mainclass contains the main GUI where theres a slot that calls a
>      > Preferences
>      > Dialog from preferencesdialog class, now in the Preferences
>     dialog the
>      > user
>      > add a string into a box, the user-input text is save on "repoText"
>      > QString,
>      > how can i use "repoText" qstring into checkrepo class?
>      > for example, checkrepo class is activated via mainclass GUI and
>     theres a
>      > messagebox that shows "repoText" to the user. where "repoText" is
>      > declared
>      > into preferencesdialog class.
>      > I hope you understand what im asking, oh and btw, sry for my english
> 
>     Ideally, you want to design your applications in such a way that the
>     application data is stored in a class separate from the classes that
>     display that data.  So you might want to consider a redesign where this
>     value is stored in a class named, say, "PreferenceData", update that
>     string as the user changes the data and is accessed by a "CheckRepo"
>     object when it is required.
> 
>     The temptation, when writing a 'simple program' to s scatter the
>     application data in the code ("make it quick -- hack it together"),
>     but as
>     soon as the program grows, as all 'simple programs' seem to do, this
>     approach becomes totally unworkable.
> 
>     --
> 
>     "It was pretty good. Even the music was nice."
>     Yogi Berra, after attending an opera
> 
> 
>     Ross Driedger
>     ross at earz.ca <mailto:ross at earz.ca>
>     _______________________________________________
>     Qt-interest mailing list
>     Qt-interest at trolltech.com <mailto:Qt-interest at trolltech.com>
>     http://lists.trolltech.com/mailman/listinfo/qt-interest
> 
> 



More information about the Qt-interest-old mailing list