Qt-interest Archive, April 2007
I'm struggling to make sense of QCoreApplication
Message 1 in thread
To no avail, I've looked everywhere else I can think of for something to get
me over the edge. So at the risk of appearing stupid, I'll ask here.
Lifting a bit of text from Qt Assistant:
int QCoreApplication::exec () [static]
Enters the main event loop and waits until exit() is called. Returns the
value that was set to exit() (which is 0 if exit() is called via quit()).
It is necessary to call this function to start event handling. The main
event loop receives events from the window system and dispatches these to
the application widgets.
That all makes sense until I get to the last sentence:
"The main event loop receives events from the window system
and dispatches these to the application widgets."
What window system? If I want a window system, I'll use the QtGui module!
What constitutes an "application widget"? Unless I am reading things
terribly wrong, I cannot create a QWidget using the QtCore module; that
requires the QtGui module, right?
What good is this QCoreApplication thing? How would I go about doing
something useful, like setting it up to process key events, for example?
Any help to get me over this hump would be greatly appreciated!
--
[ signature omitted ]
Message 2 in thread
Hi Larry,
as far as I understand QCoreApplication and the documentation all events
your applications sends and receives also have to be handled by the
underlying operating system. QCoreApplication is designed for non-gui
applications like daemons and command line tools. But still these
applications could need an event loop to connect to ports
(QTcpSocket/QTcpServer), get events from the file system
(QFileSystemWatcher) or other things.
The term "window system" is perhaps a little bit confusing. I think it
should be better replaced with "event system of the underlying operating
system".
Hope, that helps.
Best regards,
Falko
Larry Bristol schrieb:
> To no avail, I've looked everywhere else I can think of for something to get
> me over the edge. So at the risk of appearing stupid, I'll ask here.
>
> Lifting a bit of text from Qt Assistant:
>
> int QCoreApplication::exec () [static]
> Enters the main event loop and waits until exit() is called. Returns the
> value that was set to exit() (which is 0 if exit() is called via quit()).
> It is necessary to call this function to start event handling. The main
> event loop receives events from the window system and dispatches these to
> the application widgets.
>
> That all makes sense until I get to the last sentence:
> "The main event loop receives events from the window system
> and dispatches these to the application widgets."
>
> What window system? If I want a window system, I'll use the QtGui module!
> What constitutes an "application widget"? Unless I am reading things
> terribly wrong, I cannot create a QWidget using the QtCore module; that
> requires the QtGui module, right?
>
> What good is this QCoreApplication thing? How would I go about doing
> something useful, like setting it up to process key events, for example?
>
> Any help to get me over this hump would be greatly appreciated
--
[ signature omitted ]
Message 3 in thread
On 24.04.07 14:14:37, Larry Bristol wrote:
> That all makes sense until I get to the last sentence:
> "The main event loop receives events from the window system
> and dispatches these to the application widgets."
>
> What window system? If I want a window system, I'll use the QtGui module!
> What constitutes an "application widget"? Unless I am reading things
> terribly wrong, I cannot create a QWidget using the QtCore module; that
> requires the QtGui module, right?
Thats a bit misleading yeah.
> What good is this QCoreApplication thing?
To use Qt without having an windowing system running, i.e. console
applications.
> How would I go about doing
> something useful, like setting it up to process key events, for example?
For example with a QObject subclass, however the QKeyEvent's are for gui
windows. You have to read from data from the standard input. Or by other
means.
Also QCoreApplication's event loop is needed for some other things, like
QTimer (maybe QProcess or network related things).
Andreas
--
[ signature omitted ]
Message 4 in thread
Andreas Pakulat wrote:
> To use Qt without having an windowing system running, i.e. console
> applications.
Which is exactly what I am trying to do. More on that below.
[BTW: Thanks to both you and Falko for replying so quickly. Your answers
are starting to lift the veil just a little.]
>> How would I go about doing
>> something useful, like setting it up to process key events, for example?
>
> For example with a QObject subclass, however the QKeyEvent's are for gui
> windows. You have to read from data from the standard input. Or by other
> means.
That's a shame. I was sorta kinda hoping that I might be looking at
something I could use in place of ncurses (especially since I know very
little about ncurses and would rather invest my time learning more about
Qt).
> Also QCoreApplication's event loop is needed for some other things, like
> QTimer (maybe QProcess or network related things).
That seems to be the extent of it. I suppose that's a useful thing, but not
exactly what I am looking for.
What I want to do is implement the same application in two ways: once as a
GUI application, and again as a CUI (common user interface, or "console")
application. In theory, all that should require is a sound model, view,
and controller design, but I'm finding it extremely difficult to do in
practice. [Hmmm... perhaps my MVC design is not all that good! <grin>]
--
[ signature omitted ]