Qt-interest Archive, May 2007
Re: Prevent TAB change (eventfilter not working)
Message 1 in thread
_____________________________
Susan Macchia
mailto:susan@xxxxxxxxxxxx
http://www.smacchia.net
_____________________________
----- Original Message ----
From: "susan@xxxxxxxxxxxx" <susan@xxxxxxxxxxxx>
To: Gert van Loo <gert@xxxxxxxxxxxx>
Sent: Tuesday, May 1, 2007 8:52:23 AM
Subject: Re: Prevent TAB change (eventfilter not working)
Can you disable the tab if the app is running, and enable it when it is stopped instead?
----- Original Message ----
From: Gert van Loo <gert@xxxxxxxxxxxx>
To: qt-interest@xxxxxxxxxxxxx
Sent: Monday, April 30, 2007 4:30:03 PM
Subject: Prevent TAB change (eventfilter not working)
I have a set of tabs which I use as a sort of 'wizard' to configure my
application.
On the last tab the user can start/stop the application.
If the application is running the user is not allowed to make any changes.
Currently when I get the 'currentChanged' signal I check the run status.
If the application is running I give a warning message and force
the tab back to the last tab.
It is crude and it works but it is not very nice as the user is first shown
the new tab,
gets a warning message and then is forced back.
So I want to catch the currentChanged and prevent from going to the
new tab at all.
I have installed an even filter and the event filter works.
Just for testing! I have reduced the code to:
bool dm::eventFilter(QObject *o, QEvent *e )
{
if (o==maintabs)
{
if (scheduleon->currentItem()==1) // 1 is running, 0 is off
return true; // we are running ignore all events
return false; // ok to pass on events
}
}
I can set a breakpoint on 'return TRUE' and I can see that it gets to that
point.
However I also see that all events are still executed!
More interesting: If I change the
' return false; // ok to pass on events'
to
' return true; // stop any events'
I get the expected result. (Which is that my tabs go totally wrong
as no events get through).
The code is so simple that I can't understand what goes wrong.
-- Gert.
--
[ signature omitted ]
Message 2 in thread
Good idea!
I had not thought about that.
I tried 'setTabEnabled(false)' for all but the last page and
now the user can no longer switch!
Thanks!
> -----Original Message-----
> From: qt-interest-request@xxxxxxxxxxxxx
> [mailto:qt-interest-request@xxxxxxxxxxxxx]On Behalf Of Susan Macchia
> Sent: 01 May 2007 13:53
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Re: Prevent TAB change (eventfilter not working)
>
>
>
> _____________________________
> Susan Macchia
> mailto:susan@xxxxxxxxxxxx
> http://www.smacchia.net
> _____________________________
>
>
>
> ----- Original Message ----
> From: "susan@xxxxxxxxxxxx" <susan@xxxxxxxxxxxx>
> To: Gert van Loo <gert@xxxxxxxxxxxx>
> Sent: Tuesday, May 1, 2007 8:52:23 AM
> Subject: Re: Prevent TAB change (eventfilter not working)
>
> Can you disable the tab if the app is running, and enable it when
> it is stopped instead?
>
>
> ----- Original Message ----
> From: Gert van Loo <gert@xxxxxxxxxxxx>
> To: qt-interest@xxxxxxxxxxxxx
> Sent: Monday, April 30, 2007 4:30:03 PM
> Subject: Prevent TAB change (eventfilter not working)
>
>
>
> I have a set of tabs which I use as a sort of 'wizard' to configure my
> application.
> On the last tab the user can start/stop the application.
> If the application is running the user is not allowed to make any changes.
> Currently when I get the 'currentChanged' signal I check the run status.
> If the application is running I give a warning message and force
> the tab back to the last tab.
> It is crude and it works but it is not very nice as the user is
> first shown
> the new tab,
> gets a warning message and then is forced back.
>
> So I want to catch the currentChanged and prevent from going to the
> new tab at all.
> I have installed an even filter and the event filter works.
> Just for testing! I have reduced the code to:
>
> bool dm::eventFilter(QObject *o, QEvent *e )
> {
> if (o==maintabs)
> {
> if (scheduleon->currentItem()==1) // 1 is running, 0 is off
> return true; // we are running ignore all events
> return false; // ok to pass on events
> }
> }
>
> I can set a breakpoint on 'return TRUE' and I can see that it gets to that
> point.
> However I also see that all events are still executed!
>
> More interesting: If I change the
> ' return false; // ok to pass on events'
> to
> ' return true; // stop any events'
>
> I get the expected result. (Which is that my tabs go totally wrong
> as no events get through).
> The code is so simple that I can't understand what goes wrong.
>
> -- Gert.
>
>
>
>
>
>
> --
> 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/
>
>
>
>
>
>
>
> --
> 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 ]