Qt-interest Archive, January 2007
Newbie question
Message 1 in thread
Hi all.
Just started working with Qt and was hoping someone could explain the
following behavior:
I have a class that extends QMainWindow that defines some signals and
slots. I have another class that defines some slots that are
triggered by the main window's UI elements. My main method looks
like this:
int main(int argc, char** argv) {
QApplication app(argc, argv);
QVxMainWindow mw;
QVxServiceInterface service(&mw); // Object that defines the
slots that need to be called and makes the appropriate signal->slot
connections.
mw.show();
return app.exec();
}
When I click the button I have in the window, the appropriate slot
gets called (right now I only have it output text to stdout), but
then the application immediately exits "normally". Does app.exec()
not do what I think it does (i.e. create the main loop that only
breaks when I quit the application)?
Also not that I have a signal going from the service object to the
QVxMainWindow object, and when that slot receives a signal (to enable
other UI elements), the application continues to run as expected.
Thanks in advance.
-Bruno
--
[ signature omitted ]
Message 2 in thread
On 1/15/07, Bruno Trindade <bruno@xxxxxxxxx> wrote:
> Hi all.
> When I click the button I have in the window, the appropriate slot
> gets called (right now I only have it output text to stdout), but
> then the application immediately exits "normally".
What do you mean "normally"? If it exits suddenly, without you
initiated the exit, it could be hardly called "normally".
> Does app.exec()
> not do what I think it does (i.e. create the main loop that only
> breaks when I quit the application)?
Yes, it does.
> Also not that I have a signal going from the service object to the
> QVxMainWindow object, and when that slot receives a signal (to enable
> other UI elements), the application continues to run as expected.
You need to recheck your code - probably something closes app by
mistake, throws exception, crashes, etc.
--
[ signature omitted ]
Message 3 in thread
I suggest you send the code where the connect is done.
if you can create a console application to verify if some Qt message is
sent to give you some info about this behaviour.
Pavel Antokolsky aka Zigmar a Ãcrit :
> On 1/15/07, Bruno Trindade <bruno@xxxxxxxxx> wrote:
>
>> Hi all.
>> When I click the button I have in the window, the appropriate slot
>> gets called (right now I only have it output text to stdout), but
>> then the application immediately exits "normally".
>
> What do you mean "normally"? If it exits suddenly, without you
> initiated the exit, it could be hardly called "normally".
>
>> Does app.exec()
>> not do what I think it does (i.e. create the main loop that only
>> breaks when I quit the application)?
>
> Yes, it does.
>
>> Also not that I have a signal going from the service object to the
>> QVxMainWindow object, and when that slot receives a signal (to enable
>> other UI elements), the application continues to run as expected.
>
> You need to recheck your code - probably something closes app by
> mistake, throws exception, crashes, etc.
>
--
[ signature omitted ]