Qt-interest Archive, May 2007
doubts about models and threads
Message 1 in thread
HI all,
I'm quite new to QT and I come from a Java/Swing background. Reading
the "Programming with QT" book I come into a doubt: does QT support a Model
View Controller paradigm? Because it seems to me it does not, or better it
does not expose it to developers in a way they can use comfortably.
Another doubt is about threads: in Swing when you've to execute a very long
or cpu consuming task you should perform it with a SwingWorker, a separated
thread that allows the main GUI thread to be responsive to user inputs.
This avoids the GUI to be blocked while performing the thread. Does this
apply to QT too?
I'd like if somebody can answer my doubts or can point me to some tutorial
or documentation that can solve them.
Thanks,
Luca
--
[ signature omitted ]
Message 2 in thread
Hi,
> Another doubt is about threads: in Swing when you've to execute a very long
> or cpu consuming task you should perform it with a SwingWorker, a separated
> thread that allows the main GUI thread to be responsive to user inputs.
> This avoids the GUI to be blocked while performing the thread. Does this
> apply to QT too?
That's not specific to Qt or Java. In any event-based program:
1) You should cut lengthy tasks into small chunks so that the program remains
responsive (you must return to the event loop very often so that events are
processed).
2) You may also run lengthy tasks in a separate thread, but if you don't cut
them into small chunks, then you won't be able to interrupt this lengthy task
until it's finished.
3) You could also run the lengthy task in a separate process, one that is not
event-based. This would be my preferred solution, since can kill the process
to abort the lengthy task if needed.
--
[ signature omitted ]
Message 3 in thread
On 23.05.07 09:33:01, Luca Ferrari wrote:
> I'm quite new to QT and I come from a Java/Swing background. Reading
> the "Programming with QT" book I come into a doubt: does QT support a Model
> View Controller paradigm? Because it seems to me it does not, or better it
> does not expose it to developers in a way they can use comfortably.
Yes, Qt does support the MVC pattern, look at the Model and Views
chapert in the Qt4 documentation.
> Another doubt is about threads: in Swing when you've to execute a very long
> or cpu consuming task you should perform it with a SwingWorker, a separated
> thread that allows the main GUI thread to be responsive to user inputs.
> This avoids the GUI to be blocked while performing the thread. Does this
> apply to QT too?
This technique applies to any program with a user interface in any
programming language. It has nothing to do with Qt, Swing, C++ or Java.
Long and/or cpu intensive tasks should always be done in a code unit
that runs parallel to the user-interface.
> I'd like if somebody can answer my doubts or can point me to some tutorial
> or documentation that can solve them.
See the Qt documentation on doc.trolltech.com/4.3/, there are quite a
few examples that come with Qt.
Andreas
--
[ signature omitted ]
Message 4 in thread
On Wednesday 23 May 2007 09:33:01 Luca Ferrari wrote:
> HI all,
> I'm quite new to QT and I come from a Java/Swing background. Reading
> the "Programming with QT" book I come into a doubt: does QT support a Model
> View Controller paradigm? Because it seems to me it does not, or better it
> does not expose it to developers in a way they can use comfortably.
http://doc.trolltech.com/4.3/model-view-programming.html
> Another doubt is about threads: in Swing when you've to execute a very long
> or cpu consuming task you should perform it with a SwingWorker, a separated
> thread that allows the main GUI thread to be responsive to user inputs.
> This avoids the GUI to be blocked while performing the thread. Does this
> apply to QT too?
http://doc.trolltech.com/4.3/threads.html
> I'd like if somebody can answer my doubts or can point me to some tutorial
> or documentation that can solve them.
Try those, they should help :)
--
[ signature omitted ]
Message 5 in thread
(Moving reply back to qt-interest, please be sure to reply to the list and not
privately to the respondent).
Luca Ferrari wrote:
> On Wednesday 23 May 2007 your cat, walking on the keyboard, wrote:
>> On Wednesday 23 May 2007 09:33:01 Luca Ferrari wrote:
>> http://doc.trolltech.com/4.3/model-view-programming.html
>
> Thanks guys,
> just another doubt: the above manual piece states that QT uses a model-view
> approach, with the controller embedded into the view. But then comes the
> delegate classes, that can be considered as controllers for user input, so
> the model-view approach sometimes divide into a model-view-controller?
>
> Just a thought....
Yes, it does. The idea being that you only have to customize the control if
needed by your application, otherwise there is a default control that works in
the general case.
--
[ signature omitted ]
Message 6 in thread
FYI, there's a good introductory article on threads (for asynchronous database
access) in QT4 in the June 07 issue of Linux Journal.
They have published the sample code here so that might be useful as a simple
guide ftp://ftp.linuxjournal.com/pu/lj/issue158/9602.tgz
Dec
On Wednesday 23 May 2007 19:33, Luca Ferrari wrote:
> HI all,
> I'm quite new to QT and I come from a Java/Swing background. Reading
> the "Programming with QT" book I come into a doubt: does QT support a Model
> View Controller paradigm? Because it seems to me it does not, or better it
> does not expose it to developers in a way they can use comfortably.
>
> Another doubt is about threads: in Swing when you've to execute a very long
> or cpu consuming task you should perform it with a SwingWorker, a separated
> thread that allows the main GUI thread to be responsive to user inputs.
> This avoids the GUI to be blocked while performing the thread. Does this
> apply to QT too?
>
> I'd like if somebody can answer my doubts or can point me to some tutorial
> or documentation that can solve them.
>
> Thanks,
> Luca
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and information:
> http://lists.trolltech.com/qt-interest/
--
[ signature omitted ]
Message 7 in thread
Model-View-Controller is a design philosophy. It is a manner of
using components. QT does support MVC. In QT4, there are Model View
classes. The model classes have a model index which abstracts data
models. Look at the directory model for a simple example. BTW, Java
and Swing did not originate MVC. MVC was prominent in MacApp 3.0
which was C++.
M
> On Wednesday 23 May 2007 19:33, Luca Ferrari wrote:
>> HI all,
>> I'm quite new to QT and I come from a Java/Swing background. Reading
>> the "Programming with QT" book I come into a doubt: does QT
>> support a Model
>> View Controller paradigm? Because it seems to me it does not, or
>> better it
>> does not expose it to developers in a way they can use comfortably.
>>
>> Another doubt is about threads: in Swing when you've to execute a
>> very long
>> or cpu consuming task you should perform it with a SwingWorker, a
>> separated
>> thread that allows the main GUI thread to be responsive to user
>> inputs.
>> This avoids the GUI to be blocked while performing the thread.
>> Does this
>> apply to QT too?
>>
>> I'd like if somebody can answer my doubts or can point me to some
>> tutorial
>> or documentation that can solve them.
>>
>> Thanks,
>> Luca
>>
>> --
>> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx
>> with
>> "unsubscribe" in the subject or the body. List archive and
>> information:
>> http://lists.trolltech.com/qt-interest/
>
> --
--
[ signature omitted ]
Message 8 in thread
Michael Simpson wrote:
> BTW, Java and Swing did not originate MVC. MVC was prominent in
> MacApp 3.0 which was C++.
>
MVC originated in Smalltalk. ParcPlace's visualworks in particular.
The first design patterns book was written using Smalltalk...FWIW.
---
This communication contains confidential information. If you are not the intended recipient please return this email to the sender and delete it from your records.
Diese Nachricht enthält vertrauliche Informationen. Sollten Sie nicht der beabsichtigte Empfänger dieser E-mail sein, senden Sie bitte diese an den Absender zurück und löschen Sie die E-mail aus Ihrem System.
--
[ signature omitted ]