[Interest] Run Console and windows screen

K. Frank kfrank29.c at gmail.com
Sat Oct 26 00:57:41 CEST 2013


Hello Daniel!

On Fri, Oct 25, 2013 at 5:42 PM, Daniel Mota
<danielmota.producao at gmail.com> wrote:
> Hi Frank, thanks for your attention, I tried this already, but with no
> success...
>
> I have the impression that when the form opens, all my code stops, and just
> keep going when I close the form.

I don't have a clear picture of what you are trying to accomplish.
A little more detail on what you want to have happen and what
you actually see would be helpful.

Along those lines, when you say that all your "code stops," what
do you mean?  A Qt gui application is normally event driven.  There's
a main event loop for the application that handles and dispatches
mouse clicks, etc. If you open a so-called modal form, the event
loop, in effect, handles only events for the modal form until it is
closed.  So a modal form might cause the rest of your gui to "stop."

Also, how does your console come into this?  What are you
expecting your console to do while your gui app runs?

> Have you ever seen this happening?

I don't know, since I don't really know the details of what you're seeing.

Just to give you some background on how I've used the console:

I have had the main gui thread write to cout (stdout), and such output
appears in the console.  I _think_ I have had other threads write to
cout, with the output appearing in the console.  (Two notes:  I don't
remember for sure whether I have had multiple threads write to the
console; and, if you do try this, your writes from various threads may
become intermeshed unless you explicitly synchronize them.)

I have not tried to read from the console, but it wouldn't surprise me
if that would work.

Again, more detail on what you're trying to accomplish would be
helpful.

> Thanks
>
> Daniel


Best.


K. Frank


> On Fri, Oct 25, 2013 at 7:20 PM, K. Frank <kfrank29.c at gmail.com> wrote:
>>
>> Hi Daniel!
>>
>> On Fri, Oct 25, 2013 at 12:24 PM, Daniel Mota
>> <danielmota.producao at gmail.com> wrote:
>> > Hi all,
>> >
>> > just a small question:
>> >
>> > Is it possible to run a form and a console screen simultaneously?
>>
>> Yes, it is -- at least on windows.
>>
>> If you add CONFIG += console to a regular gui Qt .pro file,
>> your program will open up a console window (in addition to
>> displaying its gui) when it starts up.  If you write to cout
>> (stdout) it will show up in the console.  (I haven't tried reading
>> from cin from a console attached to a Qt gui app.)
>>
>> I've done this with Qt 4.8 on windows.  I don't know about
>> Qt 5, but I expect that it will work the same.
>>
>> > Thanks
>> >
>> > Daniel
>>
>> Good luck.
>>
>> K. Frank
>> ...



More information about the Interest mailing list